Merege fix for #7421 from trunk

[SVN r80787]
This commit is contained in:
Antony Polukhin committed 2012-09-30 16:07:32 +00:00
1 parent 8d373a0c99
commit 0920c53e23
3 files changed
+65 -8

No files matched your search

+15
View File
@@ -88,6 +88,7 @@ void test_char16_conversions();
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
void test_char32_conversions();
#endif
void test_getting_pointer_to_function();
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
@@ -125,6 +126,7 @@ unit_test::test_suite *init_unit_test_suite(int, char *[])
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
suite->add(BOOST_TEST_CASE(&test_char32_conversions));
#endif
suite->add(BOOST_TEST_CASE(&test_getting_pointer_to_function));
return suite;
}
@@ -599,4 +601,17 @@ void test_char32_conversions()
}
#endif
template <class To, class From, class Func>
To try_cast_by_ptr(const From& from, const Func& f) {
return f(from);
};
void test_getting_pointer_to_function()
{
// Just checking that &lexical_cast<To, From> is not ambiguous
BOOST_CHECK_EQUAL(100, try_cast_by_ptr<int>("100", &boost::lexical_cast<int, const char[4]>));
BOOST_CHECK_EQUAL(100, try_cast_by_ptr<int>("100", &boost::lexical_cast<int, std::string>));
BOOST_CHECK_EQUAL(std::string("100"), try_cast_by_ptr<std::string>(100, &boost::lexical_cast<std::string, int>));
}