]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/optional/sfinae_friendly_metafunctions.cpp
1 // Copyright Louis Dionne 2013-2016
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/not.hpp>
7 #include <boost/hana/optional.hpp>
8 #include <boost/hana/traits.hpp>
9 #include <boost/hana/type.hpp>
11 #include <type_traits>
13 namespace hana
= boost::hana
;
16 template <typename
...>
19 template <typename T
, typename
= void>
20 struct has_type
: std::false_type
{ };
23 struct has_type
<T
, void_t
<typename
T::type
>>
27 auto common_type_impl
= hana::sfinae([](auto t
, auto u
) -> decltype(hana::type_c
<
28 decltype(true ? hana::traits::declval(t
) : hana::traits::declval(u
))
31 template <typename T
, typename U
>
32 using common_type2
= decltype(common_type_impl(hana::type_c
<T
>, hana::type_c
<U
>));
34 static_assert(!has_type
<common_type2
<int, int*>>{}, "");
35 static_assert(std::is_same
<common_type2
<int, float>::type
, float>{}, "");