From 2c41ed0473965bc4684f74b15cbbd9250b89216b Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Tue, 16 Jan 2007 21:03:47 +0000 Subject: [PATCH] Fix for [ 1358600 ] lexical_cast & pure virtual functions & VC 8 STL [SVN r36738] --- include/boost/lexical_cast.hpp | 2 +- test/Jamfile | 1 + test/Jamfile.v2 | 1 + test/lexical_cast_abstract_test.cpp | 61 +++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 test/lexical_cast_abstract_test.cpp diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 491774a..8a0266c 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1020,7 +1020,7 @@ namespace boost , typename CharT > Target lexical_cast( - BOOST_DEDUCED_TYPENAME boost::call_traits::value_type arg, + BOOST_DEDUCED_TYPENAME boost::call_traits::param_type arg, CharT* buf, std::size_t src_len) { typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< diff --git a/test/Jamfile b/test/Jamfile index 20d8265..e1bacb5 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -30,6 +30,7 @@ DEPENDS all : test ; [ run ../numeric_cast_test.cpp ] [ run ../lexical_cast_test.cpp ../../test/build/boost_unit_test_framework ] [ run lexical_cast_loopback_test.cpp ../../test/build/boost_unit_test_framework ] + [ run lexical_cast_abstract_test.cpp ../../test/build/boost_unit_test_framework ] ; } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 0e59404..7108858 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -22,6 +22,7 @@ test-suite conversion [ run ../numeric_cast_test.cpp ] [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_abstract_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_abstract_test.cpp b/test/lexical_cast_abstract_test.cpp new file mode 100644 index 0000000..207d3a5 --- /dev/null +++ b/test/lexical_cast_abstract_test.cpp @@ -0,0 +1,61 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Sergey Shandar 2005, Alexander Nasonov, 2007. +// +// Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). +// +// Test abstract class. Bug 1358600: +// http://sf.net/tracker/?func=detail&aid=1358600&group_id=7586&atid=107586 + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include + +using namespace boost; + +void test_abstract(); + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast unit test"); + suite->add(BOOST_TEST_CASE(&test_abstract)); + + return suite; +} + +class A +{ +public: + virtual void out(std::ostream &) const = 0; +}; + +class B: public A +{ +public: + virtual void out(std::ostream &O) const { O << "B"; } +}; + +std::ostream &operator<<(std::ostream &O, const A &a) +{ + a.out(O); + return O; +}; + +void test_abstract() +{ + const A &a = B(); + BOOST_CHECK(boost::lexical_cast(a) == "B"); +} +