模板超程式設計(3):型別選擇
阿新 • • 發佈:2018-12-27
{
54 BOOST_MPL_ASSERT((boost::is_same<typename if_then_else<true,T1,T2>::type,T1>));
55 BOOST_MPL_ASSERT((boost::is_same<typename if_then_else<false,T1,T2>::type,T2>));
56
57 BOOST_MPL_ASSERT((boost::is_same<typename if_elif_else<1>::type,T1>));
58 BOOST_MPL_ASSERT((boost::is_same <typename if_elif_else<2>::type,T2>));
59 BOOST_MPL_ASSERT((boost::is_same<typename if_elif_else<4>::type,T4>));
60 BOOST_MPL_ASSERT((boost::is_same<typename if_elif_else<8>::type,T8>));
61 BOOST_MPL_ASSERT((boost::is_same<typename if_elif_else<10>::type, void>));
62
63 BOOST_MPL_ASSERT((boost::is_same<typename switch_case<1>::type,T1>));
64 BOOST_MPL_ASSERT((boost::is_same<typename switch_case<2>::type,T2>));
65 BOOST_MPL_ASSERT((boost::is_same<typename switch_case<4>::type,T4>));
66 BOOST_MPL_ASSERT((boost::is_same <typename switch_case<8>::type,T8>));
67 BOOST_MPL_ASSERT((boost::is_same<typename switch_case<10>::type,void>));
68
69 return0;
70}
54 BOOST_MPL_ASSERT((boost::is_same<typename if_then_else<true,T1,T2>::type,T1>));
55 BOOST_MPL_ASSERT((boost::is_same<typename if_then_else<false,T1,T2>::type,T2>));
56
57 BOOST_MPL_ASSERT((boost::is_same<typename if_elif_else<1>::type,T1>));
58 BOOST_MPL_ASSERT((boost::is_same
59 BOOST_MPL_ASSERT((boost::is_same<typename if_elif_else<4>::type,T4>));
60 BOOST_MPL_ASSERT((boost::is_same<typename if_elif_else<8>::type,T8>));
61 BOOST_MPL_ASSERT((boost::is_same<typename if_elif_else<10>::type,
62
63 BOOST_MPL_ASSERT((boost::is_same<typename switch_case<1>::type,T1>));
64 BOOST_MPL_ASSERT((boost::is_same<typename switch_case<2>::type,T2>));
65 BOOST_MPL_ASSERT((boost::is_same<typename switch_case<4>::type,T4>));
66 BOOST_MPL_ASSERT((boost::is_same
67 BOOST_MPL_ASSERT((boost::is_same<typename switch_case<10>::type,void>));
68
69 return0;
70}