Boost C++ Libraries: Ticket #12299: User-defined conversion operator from a wrapper class to a boost/multiprecision floating-point type does not compile. https://svn.boost.org/trac10/ticket/12299 <p> please see the attached file. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12299 Trac 1.4.3 Ulrich Mutze <ulrichmutze@…> Thu, 23 Jun 2016 15:30:14 GMT attachment set https://svn.boost.org/trac10/ticket/12299 https://svn.boost.org/trac10/ticket/12299 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cpp</span> </li> </ul> Ticket John Maddock Fri, 24 Jun 2016 17:41:50 GMT <link>https://svn.boost.org/trac10/ticket/12299#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12299#comment:1</guid> <description> <p> I'm having a hard time figuring out why this would work for type double actually - though it clearly does so.... do you have a reference to which part of the standard requires the conversion operators to be invoked in this case? </p> <p> BTW if you typedef R to complex&lt;double&gt; it fails for the same reason as Boost does. </p> <p> A quick and dirty workaround would be to add arithmetic operators for type R1: </p> <pre class="wiki">inline R operator+(const R1&amp; a, const R1&amp; b) { return (R)a + (R)b; } </pre><p> I could also add more overloaded operators for type number to handle this specific case, but I'm not entirely sure what the consequences would be (other than even longer compile times). </p> <p> Thanks for reporting this, it's an interesting and somewhat perplexing corner case...! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 24 Jun 2016 19:58:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12299#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12299#comment:2</guid> <description> <p> I'm having a hard time too understanding why my compiler does not respect what Stroustrup's 'The C++ programming language', 4th edition, says on the first half of p. 544. For exemplification he defines a class Tiny of small integers and endows it with the arithmetic facilities of type int by providing a member function Tiny::operator int()const which is asserted to effect implicit conversion (if a direct function call is not defined). Not being really familiar with the standard I simply googled 'conversion operator C++ standard' and got a page that seemed to me expressing the same in a more formal language. On the other hand, all my attempts to define 'R' as a simple self-made class, for which the intended type conversion would work, failed. So, the problem seems to be one of modern C++ implementations more than one of boost/multiprecision. However, it should be noted that (at least on my system) R1 works as intended for R defined as mpreal. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 25 Jun 2016 12:25:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12299#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12299#comment:3</guid> <description> <blockquote class="citation"> <p> However, it should be noted that (at least on my system) R1 works as intended for R defined as mpreal. </p> </blockquote> <p> Not for me with mpreal 3.6.2: I get the same error as I see with Boost.Multiprecision... ah wait this is with VC++, with GCC it compiles OK. I suspect GCC accepts the code only because mpreal and it's overloaded operators are non-templates. Not sure about that, as I still don't really understand why this would work in the first place.... in any case having thought about this some more I don't actually see any way to fix this inside Multiprecision :( </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 28 Jun 2016 10:00:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12299#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12299#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/12299#comment:3" title="Comment 3">johnmaddock</a>: </p> <blockquote class="citation"> <blockquote class="citation"> <p> However, it should be noted that (at least on my system) R1 works as intended for R defined as mpreal. </p> </blockquote> <p> Not for me with mpreal 3.6.2: I get the same error as I see with Boost.Multiprecision... ah wait this is with VC++, with GCC it compiles OK. I suspect GCC accepts the code only because mpreal and it's overloaded operators are non-templates. Not sure about that, as I still don't really understand why this would work in the first place.... in any case having thought about this some more I don't actually see any way to fix this inside Multiprecision :( </p> </blockquote> <p> I agree. If it is a problem (I'm convinced that it is one) it is one for GCC. So I sent a bugreport to them where it got a Ticket 71658. When the matter is clarified there, I probably will come back to boost/multiprecision. Meanwhile I don't expect action from your side. Thanks a lot so far! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 30 Dec 2017 19:04:41 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/12299#comment:5 https://svn.boost.org/trac10/ticket/12299#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> Ticket