1 #ifndef BOOST_TYPE_TRAITS_DETAIL_MP_DEFER_HPP_INCLUDED 2 #define BOOST_TYPE_TRAITS_DETAIL_MP_DEFER_HPP_INCLUDED 3 4 // 5 // Copyright 2015 Peter Dimov 6 // 7 // Distributed under the Boost Software License, Version 1.0. 8 // See accompanying file LICENSE_1_0.txt or copy at 9 // http://www.boost.org/LICENSE_1_0.txt 10 // 11 12 #include <boost/type_traits/integral_constant.hpp> 13 #include <boost/type_traits/conditional.hpp> 14 15 namespace boost 16 { 17 18 namespace type_traits_detail 19 { 20 21 // mp_valid 22 // implementation by Bruno Dutra (by the name is_evaluable) 23 24 template<template<class...> class F, class... T> 25 struct mp_valid_impl 26 { 27 template<template<class...> class G, class = G<T...>> 28 static boost::true_type check_s(int); 29 30 template<template<class...> class> 31 static boost::false_type check_s(...); 32 33 using type = decltype(check_s<F>(0)); 34 }; 35 36 template<template<class...> class F, class... T> 37 using mp_valid = typename mp_valid_impl<F, T...>::type; 38 39 // mp_defer 40 41 struct mp_empty 42 { 43 }; 44 45 template<template<class...> class F, class... T> struct mp_defer_impl 46 { 47 using type = F<T...>; 48 }; 49 50 template<template<class...> class F, class... T> using mp_defer = typename boost::conditional<mp_valid<F, T...>::value, mp_defer_impl<F, T...>, mp_empty>::type; 51 52 } // namespace type_traits_detail 53 54 } // namespace boost 55 56 #endif // #ifndef BOOST_TYPE_TRAITS_DETAIL_MP_DEFER_HPP_INCLUDED 57