diff --git a/include/boost/hana/functional/overload.hpp b/include/boost/hana/functional/overload.hpp index d8ce96a5ac..522f241d54 100644 --- a/include/boost/hana/functional/overload.hpp +++ b/include/boost/hana/functional/overload.hpp @@ -12,6 +12,7 @@ Distributed under the Boost Software License, Version 1.0. #include #include +#include BOOST_HANA_NAMESPACE_BEGIN @@ -47,7 +48,10 @@ BOOST_HANA_NAMESPACE_BEGIN using overload_t::type::operator(); using overload_t::type::operator(); - template + template >::value + >> constexpr explicit overload_t(F_&& f, G_&& ...g) : overload_t::type(static_cast(f)) , overload_t::type(static_cast(g)...) diff --git a/test/issues/github_412.cpp b/test/issues/github_412.cpp new file mode 100644 index 0000000000..a8e66964cd --- /dev/null +++ b/test/issues/github_412.cpp @@ -0,0 +1,17 @@ +#include "boost/hana.hpp" + +constexpr int f() { return 12; } +constexpr int g(int) { return 42; } + + + +// This test makes sure that overload can +// be copy constructed +int main() { + auto a = boost::hana::overload(f,g); + auto b(a); + + + BOOST_HANA_RUNTIME_CHECK(b() == 12); + BOOST_HANA_RUNTIME_CHECK(b(1) == 42); +}