1 // Copyright Louis Dionne 2013-2017
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 #ifndef TEST_CONCEPT_CONSTANT_MINIMAL_HPP
6 #define TEST_CONCEPT_CONSTANT_MINIMAL_HPP
8 #include <boost/hana/concept/constant.hpp>
9 #include <boost/hana/core/when.hpp>
10 #include <boost/hana/fwd/core/to.hpp>
11 #include <boost/hana/value.hpp>
15 struct minimal_constant_tag {
19 template <typename T, T v>
20 struct minimal_constant {
21 using hana_tag = minimal_constant_tag<T>;
22 static constexpr T value_ = v;
25 namespace boost { namespace hana {
27 struct value_impl<minimal_constant_tag<T>> {
29 static constexpr T apply() { return N::value_; }
32 template <typename T, typename C>
33 struct to_impl<minimal_constant_tag<T>, C, hana::when<
34 hana::Constant<C>::value &&
35 hana::is_convertible<typename C::value_type, T>::value
37 : hana::embedding<hana::is_embedded<typename C::value_type, T>::value>
40 static constexpr auto apply(N const&)
41 { return minimal_constant<T, hana::value<N>()>{}; }
43 }} // end namespace boost::hana
45 #endif // !TEST_CONCEPT_CONSTANT_MINIMAL_HPP