From 016f0c076f453b297ad4e808b9a033380d5605fd Mon Sep 17 00:00:00 2001 From: DarthRubik Date: Sat, 30 Jun 2018 20:21:53 -0500 Subject: [PATCH 1/2] Making overload_t's copy constructor have priority So currently the copy constructor for the overload_t does not take precendent over the other templated constructor. This means a simple function like the following fails: void foo() { auto a = hana::overload(f1,f2); auto b(a); //Error } To fix this I added a enable_if to turn off the constructor when not applicable......... --- include/boost/hana/functional/overload.hpp | 6 +++++- test/issues/github_412.cpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/issues/github_412.cpp diff --git a/include/boost/hana/functional/overload.hpp b/include/boost/hana/functional/overload.hpp index d8ce96a5ac..e628e85dea 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); +} From 784fa229f7d9ac5045c0851e0427ee65a3335775 Mon Sep 17 00:00:00 2001 From: DarthRubik Date: Tue, 3 Jul 2018 15:40:28 -0500 Subject: [PATCH 2/2] Fixing trailing white space.... I am new to this project, and did not realize that I needed to get rid of trailing white space...but know I have removed the offending space..... --- include/boost/hana/functional/overload.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/hana/functional/overload.hpp b/include/boost/hana/functional/overload.hpp index e628e85dea..522f241d54 100644 --- a/include/boost/hana/functional/overload.hpp +++ b/include/boost/hana/functional/overload.hpp @@ -48,7 +48,7 @@ BOOST_HANA_NAMESPACE_BEGIN using overload_t::type::operator(); using overload_t::type::operator(); - template >::value >>