]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | // |
2 | // Copyright Louis Dionne 2013-2017 | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0. | |
5 | //(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
6 | // | |
7 | #ifndef BOOST_GIL_DETAIL_STD_COMMON_TYPE_HPP | |
8 | #define BOOST_GIL_DETAIL_STD_COMMON_TYPE_HPP | |
9 | ||
10 | #include <type_traits> | |
11 | #include <utility> | |
12 | ||
13 | namespace boost { namespace gil { namespace detail { | |
14 | ||
15 | // Defines a SFINAE-friendly version of `std::common_type`. | |
16 | // | |
17 | // Based on boost/hana/detail/std_common_type.hpp | |
18 | // Equivalent to `std::common_type`, except it is SFINAE-friendly and | |
19 | // does not support custom specializations. | |
20 | ||
21 | template <typename T, typename U, typename = void> | |
22 | struct std_common_type {}; | |
23 | ||
24 | template <typename T, typename U> | |
25 | struct std_common_type | |
26 | < | |
27 | T, U, | |
28 | decltype((void)(true ? std::declval<T>() : std::declval<U>())) | |
29 | > | |
30 | { | |
31 | using type = typename std::decay | |
32 | < | |
33 | decltype(true ? std::declval<T>() : std::declval<U>()) | |
34 | >::type; | |
35 | }; | |
36 | ||
37 | }}} // namespace boost::gil::detail | |
38 | ||
39 | #endif |