test_has_type_ct_compile.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. // (C) Copyright Edward Diener 2011
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. #include "test_has_type.hpp"
  6. #include <boost/mpl/assert.hpp>
  7. #include <boost/mpl/placeholders.hpp>
  8. #include <boost/type_traits/is_same.hpp>
  9. using namespace boost::mpl::placeholders;
  10. int main()
  11. {
  12. // You can always instantiate without compiler errors
  13. TheInteger<AType::BType,boost::is_same<short,_> > aVar;
  14. BOOST_TTI_HAS_TYPE_GEN(NoOtherType)<AnotherType,boost::is_same<double,_> > aVar2;
  15. // Compile time asserts
  16. BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnIntType)<AType,boost::is_same<int,_> >));
  17. BOOST_MPL_ASSERT((NameStruct<AType,boost::is_same<AType::AStructType,_> >));
  18. BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnIntTypeReference)<AType,boost::is_same<int &,_> >));
  19. BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(BType)<AType,boost::is_same<AType::BType,_> >));
  20. BOOST_MPL_ASSERT((TheInteger<AType::BType,boost::is_same<int,_> >));
  21. BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(CType)<AType::BType,boost::is_same<AType::BType::CType,_> >));
  22. BOOST_MPL_ASSERT((BOOST_TTI_HAS_TYPE_GEN(AnotherIntegerType)<AType::BType::CType,boost::is_same<int,_> >));
  23. BOOST_MPL_ASSERT((SomethingElse<AnotherType,boost::is_same<AType::AnIntType,_> >));
  24. return 0;
  25. }