is_maybe.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright Daniel Wallin, David Abrahams 2010.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PARAMETER_IS_MAYBE_050329_HPP
  6. #define BOOST_PARAMETER_IS_MAYBE_050329_HPP
  7. namespace boost { namespace parameter { namespace aux {
  8. struct maybe_base
  9. {
  10. };
  11. }}} // namespace boost::parameter::aux
  12. #if defined(BOOST_PARAMETER_CAN_USE_MP11)
  13. #include <type_traits>
  14. namespace boost { namespace parameter { namespace aux {
  15. template <typename T>
  16. using is_maybe = ::std::is_base_of<
  17. ::boost::parameter::aux::maybe_base
  18. , typename ::std::remove_const<T>::type
  19. >;
  20. }}} // namespace boost::parameter::aux
  21. #else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
  22. #include <boost/mpl/bool.hpp>
  23. #include <boost/mpl/if.hpp>
  24. #include <boost/type_traits/is_base_of.hpp>
  25. #include <boost/type_traits/remove_const.hpp>
  26. namespace boost { namespace parameter { namespace aux {
  27. template <typename T>
  28. struct is_maybe
  29. : ::boost::mpl::if_<
  30. ::boost::is_base_of<
  31. ::boost::parameter::aux::maybe_base
  32. , typename ::boost::remove_const<T>::type
  33. >
  34. , ::boost::mpl::true_
  35. , ::boost::mpl::false_
  36. >::type
  37. {
  38. };
  39. }}} // namespace boost::parameter::aux
  40. #endif // BOOST_PARAMETER_CAN_USE_MP11
  41. #endif // include guard