has_result_type.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //-----------------------------------------------------------------------------
  2. // boost variant/detail/has_result_type.hpp header file
  3. // See http://www.boost.org for updates, documentation, and revision history.
  4. //-----------------------------------------------------------------------------
  5. //
  6. // Copyright (c) 2014-2019 Antony Polukhin
  7. //
  8. // Distributed under the Boost Software License, Version 1.0. (See
  9. // accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. #ifndef BOOST_VARIANT_DETAIL_HAS_RESULT_TYPE_HPP
  12. #define BOOST_VARIANT_DETAIL_HAS_RESULT_TYPE_HPP
  13. #include <boost/config.hpp>
  14. #include <boost/type_traits/remove_reference.hpp>
  15. namespace boost { namespace detail { namespace variant {
  16. template <typename T >
  17. struct has_result_type {
  18. private:
  19. typedef char yes;
  20. typedef struct { char array[2]; } no;
  21. template<typename C> static yes test(typename boost::remove_reference<typename C::result_type>::type*);
  22. template<typename C> static no test(...);
  23. public:
  24. BOOST_STATIC_CONSTANT(bool, value = sizeof(test<T>(0)) == sizeof(yes));
  25. };
  26. }}} // namespace boost::detail::variant
  27. #endif // BOOST_VARIANT_DETAIL_HAS_RESULT_TYPE_HPP