// Boost.TypeErasure library // // Copyright 2011 Steven Watanabe // // 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) // // $Id$ #include #include #include #include #include #define BOOST_TEST_MAIN #include using namespace boost::type_erasure; template struct common : ::boost::mpl::vector< copy_constructible, typeid_ > {}; typedef any > > any1_type; struct test_class { int i; }; test_class operator+(const test_class& lhs, const any1_type& rhs) { test_class result = { lhs.i + any_cast(rhs) }; return result; } BOOST_AUTO_TEST_CASE(test_basic) { typedef boost::mpl::vector, addable<_self, any1_type> > test_concept; any1_type a1(1); test_class v = { 2 }; any x(v); any y(x + a1); BOOST_CHECK_EQUAL(any_cast(y).i, 3); } BOOST_AUTO_TEST_CASE(test_relaxed) { typedef boost::mpl::vector, addable<_a, any1_type>, relaxed> test_concept; typedef boost::mpl::vector, addable<_b, any1_type>, relaxed> dest_concept; any1_type a1(1); test_class v = { 2 }; any x(v); any y(x + a1); BOOST_CHECK_EQUAL(any_cast(y).i, 3); any z(x); }