/////////////////////////////////////////////////////////////////////////////// // make.hpp // // Copyright 2008 Eric Niebler. 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) #define BOOST_TEST_MAIN #include #include #include #include #include namespace mpl = boost::mpl; namespace proto = boost::proto; using proto::_; template struct type2type {}; template struct wrapper { T t_; explicit wrapper(T const & t = T()) : t_(t) {} }; template struct careful { typedef typename T::not_there not_there; }; // Test that when no substitution is done, we don't instantiate templates struct MakeTest1 : proto::make< type2type< careful > > {}; BOOST_AUTO_TEST_CASE(make_test1) { proto::terminal::type i = {42}; type2type< careful > res = MakeTest1()(i); } // Test that when substitution is done, and there is no nested ::type // typedef, the result is the wrapper struct MakeTest2 : proto::make< wrapper< proto::_value > > {}; BOOST_AUTO_TEST_CASE(make_test2) { proto::terminal::type i = {42}; wrapper res = MakeTest2()(i); BOOST_CHECK_EQUAL(res.t_, 0); } // Test that when substitution is done, and there is no nested ::type // typedef, the result is the wrapper struct MakeTest3 : proto::make< wrapper< proto::_value >(proto::_value) > {}; BOOST_AUTO_TEST_CASE(make_test3) { proto::terminal::type i = {42}; wrapper res = MakeTest3()(i); BOOST_CHECK_EQUAL(res.t_, 42); } // Test that when substitution is done, and there is no nested ::type // typedef, the result is the wrapper struct MakeTest4 : proto::make< mpl::identity< proto::_value >(proto::_value) > {}; BOOST_AUTO_TEST_CASE(make_test4) { proto::terminal::type i = {42}; int res = MakeTest4()(i); BOOST_CHECK_EQUAL(res, 42); }