From 52eb8768f2e84d22a037375863b8a6da2145ae24 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sun, 22 Feb 2015 00:11:04 +0900 Subject: [PATCH] Add test for #9418, abstract types for key of map. https://svn.boost.org/trac/boost/ticket/9418 --- test/sequence/map.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/sequence/map.cpp b/test/sequence/map.cpp index 8795dda0..8dada167 100644 --- a/test/sequence/map.cpp +++ b/test/sequence/map.cpp @@ -38,6 +38,11 @@ struct copy_all } }; +struct abstract +{ + virtual void foo() = 0; +}; + int main() { @@ -54,7 +59,8 @@ main() { typedef map< pair - , pair > + , pair + , pair > map_type; BOOST_MPL_ASSERT((traits::is_associative)); @@ -62,23 +68,29 @@ main() map_type m( make_pair('X') - , make_pair("Men")); + , make_pair("Men") + , make_pair(2)); std::cout << at_key(m) << std::endl; std::cout << at_key(m) << std::endl; + std::cout << at_key(m) << std::endl; BOOST_TEST(at_key(m) == 'X'); BOOST_TEST(at_key(m) == "Men"); + BOOST_TEST(at_key(m) == 2); BOOST_STATIC_ASSERT(( boost::is_same::type, char>::value)); BOOST_STATIC_ASSERT(( boost::is_same::type, std::string>::value)); + BOOST_STATIC_ASSERT(( + boost::is_same::type, int>::value)); std::cout << m << std::endl; BOOST_STATIC_ASSERT((boost::fusion::result_of::has_key::value)); BOOST_STATIC_ASSERT((boost::fusion::result_of::has_key::value)); + BOOST_STATIC_ASSERT((boost::fusion::result_of::has_key::value)); BOOST_STATIC_ASSERT((!boost::fusion::result_of::has_key::value)); std::cout << deref_data(begin(m)) << std::endl; @@ -86,15 +98,19 @@ main() BOOST_TEST(deref_data(begin(m)) == 'X'); BOOST_TEST(deref_data(fusion::next(begin(m))) == "Men"); + BOOST_TEST(deref_data(fusion::next(next(begin(m)))) == 2); BOOST_STATIC_ASSERT((boost::is_same::type>::type, int>::value)); BOOST_STATIC_ASSERT((boost::is_same::type>::type>::type, double>::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::type>::type>::type, abstract>::value)); BOOST_STATIC_ASSERT((boost::is_same::type>::type, char>::value)); BOOST_STATIC_ASSERT((boost::is_same::type>::type>::type, std::string>::value)); + BOOST_STATIC_ASSERT((boost::is_same::type>::type>::type>::type, int>::value)); // Test random access interface. pair a = at_c<0>(m); (void) a; pair b = at_c<1>(m); + pair c = at_c<2>(m); } // iterators & random access interface.