/* @copyright Louis Dionne 2014 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #include #include #include #include #include using namespace boost::hana; template void check_convert(From from, To to_) { assert(to(from) == to_); static_assert(std::is_same(from)), To>{}, ""); } struct Datatype { int value; using hana_datatype = Datatype; constexpr bool operator==(Datatype x) { return value == x.value; } }; struct other_ctor { int value; using hana_datatype = Datatype; constexpr bool operator==(other_ctor x) { return value == x.value; } }; int main() { check_convert("abcdef", std::string{"abcdef"}); check_convert(int{1}, double{1}); check_convert(double{1}, int{1}); check_convert(std::true_type{}, int{1}); check_convert(std::false_type{}, int{0}); check_convert(Datatype{1}, Datatype{1}); check_convert(other_ctor{1}, other_ctor{1}); }