Boost C++ Libraries: Ticket #514: lexical_cast & pure virtual functions & VC 8 STL https://svn.boost.org/trac10/ticket/514 <pre class="wiki">VC 8.0 can't compile the valid code: ===== ===== #include &lt;boost/lexical_cast.hpp&gt; class A { public: virtual void out(std::ostream &amp;) const = 0; }; class B: public A { public: virtual void out(std::ostream &amp;O) const { O &lt;&lt; "B"; } }; std::ostream &amp;operator&lt;&lt;(std::ostream &amp;O, const A &amp;a) { a.out(O); return O; }; int main() { const A &amp;a = B(); boost::lexical_cast&lt;std::string&gt;(a); return 0; } ===== ===== The problem occurs in VC STL: ===== ===== c:\program files\microsoft visual studio 8\vc\include\limits(102) : error C2259: 'A' : cannot instantiate abstract class ===== ===== However, should boost::lexical_cast use std::numeric_cast in this case? </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/514 Trac 1.4.3 redi Fri, 18 Nov 2005 01:31:45 GMT <link>https://svn.boost.org/trac10/ticket/514#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/514#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=426241 The code is not valid, because the type of lexical_cast's Source template argument must be CopyConstructible http://boost.org/libs/conversion/lexical_cast.htm#lexical_cast </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>nobody</dc:creator> <pubDate>Tue, 29 Nov 2005 12:39:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/514#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/514#comment:2</guid> <description> <pre class="wiki">Logged In: NO Perhaps the a being a reference creates the confusion here? The type of a is const &amp; A. And that (as a reference) is copy constructible, even though A is not. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>alnsn</dc:creator> <pubDate>Mon, 18 Sep 2006 15:29:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/514#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/514#comment:3</guid> <description> <pre class="wiki">Logged In: YES user_id=369903 In my opinion, it is an important use-case. I'd change requirements from - Both Source and Target are CopyConstructible [20.1.3]. to - Target is CopyConstructible [20.1.3]. - Source is CopyConstructible or, if not that, Source is polymorphic and the source value refers to an object with dynamic type SourceDyn which is CopyConstructible and operator&lt;&lt; called for Source is equivalent to operator&lt;&lt; called for SourceDyn. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>kevlin</dc:creator> <pubDate>Wed, 27 Sep 2006 12:39:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/514#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/514#comment:4</guid> <description> <pre class="wiki">Logged In: YES user_id=32864 I do not believe that there is any longer a reasone that Source needs to be restricted to being CopyConstructible. There were reasons for this in the past, but those have now passed and the requirements can be loosened so that the only requirement on Source is that it is OutputStreamable. This would result in the requirements for the two parameters being as follows: Source: OutputStreamable Target: InputStreamable &amp;&amp; CopyConstructible &amp;&amp; DefaultConstructible </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>alnsn</dc:creator> <pubDate>Tue, 16 Jan 2007 22:26:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/514#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/514#comment:5</guid> <description> <pre class="wiki">Logged In: YES user_id=369903 Originator: NO Fixed in HEAD. Affected files: M ./boost/lexical_cast.hpp M ./boost/detail/lcast_precision.hpp M ./libs/conversion/lexical_cast.htm M ./libs/conversion/test/Jamfile M ./libs/conversion/test/Jamfile.v2 A ./libs/conversion/test/lexical_cast_abstract_test.cpp Sergey, please check and close. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>alnsn</dc:creator> <pubDate>Wed, 24 Jan 2007 14:39:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/514#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/514#comment:6</guid> <description> <pre class="wiki">Logged In: YES user_id=369903 Originator: NO See also thread [boost] numeric_limits&lt;Abstract&gt; or how to fix 1358600? http://lists.boost.org/Archives/boost/2007/01/index.php especially John Maddock's proposal http://lists.boost.org/Archives/boost/2007/01/115765.php and my reply. </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>alnsn</dc:creator> <pubDate>Wed, 24 Jan 2007 14:42:29 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/514#comment:7 https://svn.boost.org/trac10/ticket/514#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket