push_back.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright Steven Watanabe 2009
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/mpl for documentation.
  8. // $Id$
  9. // $Date: 2008-10-10 02:21:07 -0700 (Fri, 10 Oct 2008) $
  10. // $Revision: 49240 $
  11. #include <boost/mpl/push_back.hpp>
  12. #include <boost/mpl/aux_/test.hpp>
  13. struct no_push_back_tag {};
  14. struct no_push_back
  15. {
  16. typedef no_push_back_tag tag;
  17. };
  18. struct has_push_back_tag {};
  19. struct with_push_back
  20. {
  21. typedef has_push_back_tag tag;
  22. };
  23. namespace boost { namespace mpl {
  24. template<>
  25. struct push_back_impl< has_push_back_tag >
  26. {
  27. template<class Seq, class T> struct apply
  28. {
  29. typedef no_push_back type;
  30. };
  31. };
  32. }}
  33. MPL_TEST_CASE()
  34. {
  35. MPL_ASSERT_NOT(( has_push_back< no_push_back > ));
  36. MPL_ASSERT(( has_push_back< with_push_back > ));
  37. typedef push_back< with_push_back , int >::type test;
  38. MPL_ASSERT(( is_same< test, no_push_back > ));
  39. }