abstract.cpp 979 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/utility/identity_type
  6. #include <boost/utility/identity_type.hpp>
  7. #include <boost/static_assert.hpp>
  8. #include <boost/type_traits/add_reference.hpp>
  9. #include <boost/type_traits/remove_reference.hpp>
  10. //[abstract
  11. #define TMP_ASSERT(metafunction) \
  12. BOOST_STATIC_ASSERT(metafunction::value)
  13. template<typename T, bool b>
  14. struct abstract {
  15. static const bool value = b;
  16. virtual void f(T const& x) = 0; // Pure virtual function.
  17. };
  18. TMP_ASSERT(
  19. boost::remove_reference< // Add and remove
  20. BOOST_IDENTITY_TYPE(( // reference for
  21. boost::add_reference< // abstract type.
  22. abstract<int, true>
  23. >::type
  24. ))
  25. >::type
  26. );
  27. //]
  28. int main() { return 0; }