test_has_mem_fun_cv_compile.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // (C) Copyright Edward Diener 2013
  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_mem_fun.hpp"
  6. #include <boost/mpl/assert.hpp>
  7. int main()
  8. {
  9. // You can always instantiate without compiler errors even if the member function does not exist
  10. BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(someFunctionMember)<AnotherType,double,boost::mpl::vector<short,short,long,int>,boost::function_types::const_qualified> aVar1;
  11. // Use const enclosing type
  12. BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AnotherConstFunction)<const AnotherType,int,boost::mpl::vector<AType *, short> >));
  13. BOOST_MPL_ASSERT((AskIfConst<const AType,void,boost::mpl::vector<float,double> >));
  14. // Use const_qualified
  15. BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AConstFunction)<AType,double,boost::mpl::vector<long,char>,boost::function_types::const_qualified>));
  16. BOOST_MPL_ASSERT((StillTest<AnotherType,AType,boost::mpl::vector<int>,boost::function_types::const_qualified>));
  17. // Use volatile enclosing type
  18. BOOST_MPL_ASSERT((AnVol<volatile AnotherType,int,boost::mpl::vector<AType *,short> >));
  19. BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(AVolatileFunction)<volatile AType,double,boost::mpl::vector<long,char> >));
  20. // Use volatile_qualified
  21. BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillVolatile)<AnotherType,bool,boost::mpl::vector<int>,boost::function_types::volatile_qualified>));
  22. BOOST_MPL_ASSERT((Volly<AType,void,boost::mpl::vector<float,double>,boost::function_types::volatile_qualified>));
  23. // Use const volatile enclosing type
  24. BOOST_MPL_ASSERT((CVAnother<const volatile AnotherType,int,boost::mpl::vector<AType *,short> >));
  25. BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(StillCV)<const volatile AnotherType,short,boost::mpl::vector<int> >));
  26. // Use cv_qualified
  27. BOOST_MPL_ASSERT((BOOST_TTI_HAS_MEMBER_FUNCTION_GEN(ConstVolFunction)<AType,void,boost::mpl::vector<float,double>,boost::function_types::cv_qualified>));
  28. BOOST_MPL_ASSERT((CVBoth<AType,double,boost::mpl::vector<long,char>,boost::function_types::cv_qualified>));
  29. return 0;
  30. }