test_interface_order.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Boost.TypeErasure library
  2. //
  3. // Copyright 2011 Steven Watanabe
  4. //
  5. // Distributed under the Boost Software License Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // $Id$
  10. #include <boost/type_erasure/any.hpp>
  11. #include <boost/type_erasure/builtin.hpp>
  12. #include <boost/mpl/vector.hpp>
  13. #include <boost/mpl/assert.hpp>
  14. #include <boost/type_traits/is_same.hpp>
  15. using namespace boost::type_erasure;
  16. namespace mpl = boost::mpl;
  17. template<class T = _self>
  18. struct common : mpl::vector<
  19. copy_constructible<T>
  20. > {};
  21. template<class T = _self>
  22. struct concept1 : mpl::vector<copy_constructible<T> > {};
  23. template<class T = _self>
  24. struct concept2 : mpl::vector<concept1<T> > {};
  25. namespace boost {
  26. namespace type_erasure {
  27. template<class T, class Base>
  28. struct concept_interface<concept1<T>, Base, T> : Base
  29. {
  30. typedef int id_type;
  31. };
  32. template<class T, class Base>
  33. struct concept_interface<concept2<T>, Base, T> : Base
  34. {
  35. typedef char id_type;
  36. };
  37. }
  38. }
  39. BOOST_MPL_ASSERT((boost::is_same<any<concept2<> >::id_type, char>));
  40. BOOST_MPL_ASSERT((boost::is_same<any<mpl::vector<concept2<>, concept1<> > >::id_type, char>));
  41. BOOST_MPL_ASSERT((boost::is_same<any<mpl::vector<concept1<>, concept2<> > >::id_type, char>));