From fad52fc9125f29047c8b8e7bfa7c3de0dc4d44cd Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 16 Mar 2016 12:58:49 -0500 Subject: [PATCH] Fixes for issue #118 --- include/fit/by.hpp | 15 ++++++--------- test/by.cpp | 5 +++++ test/capture.cpp | 8 +++++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/fit/by.hpp b/include/fit/by.hpp index 8ec13e6..177e7b1 100644 --- a/include/fit/by.hpp +++ b/include/fit/by.hpp @@ -72,6 +72,7 @@ #include #include #include +#include #include namespace fit { @@ -160,19 +161,20 @@ template struct by_adaptor; template -struct by_adaptor : detail::callable_base, detail::callable_base +struct by_adaptor : detail::compressed_pair, detail::callable_base> { typedef by_adaptor fit_rewritable_tag; + typedef detail::compressed_pair, detail::callable_base> base; template constexpr const detail::callable_base& base_function(Ts&&... xs) const { - return always_ref(*this)(xs...); + return this->second(xs...);; } template constexpr const detail::callable_base& base_projection(Ts&&... xs) const { - return always_ref(*this)(xs...); + return this->first(xs...); } struct by_failure @@ -191,12 +193,7 @@ struct by_adaptor : detail::callable_base, detail::callable_base : failure_map> {}; - FIT_INHERIT_DEFAULT(by_adaptor, detail::callable_base, F) - - template), FIT_ENABLE_IF_CONVERTIBLE(G, detail::callable_base)> - constexpr by_adaptor(P&& p, G&& f) - : detail::callable_base(FIT_FORWARD(P)(p)), detail::callable_base(FIT_FORWARD(G)(f)) - {} + FIT_INHERIT_CONSTRUCTOR(by_adaptor, base) FIT_RETURNS_CLASS(by_adaptor); diff --git a/test/by.cpp b/test/by.cpp index 817d0eb..aa1eb97 100644 --- a/test/by.cpp +++ b/test/by.cpp @@ -132,3 +132,8 @@ FIT_TEST_CASE() { FIT_STATIC_TEST_CHECK(constexpr_check_each()(bool_())); } + +FIT_TEST_CASE() +{ + fit::by(fit::identity, fit::identity)(0); +} diff --git a/test/capture.cpp b/test/capture.cpp index 08b57df..a0f75ba 100644 --- a/test/capture.cpp +++ b/test/capture.cpp @@ -1,5 +1,6 @@ -#include "test.hpp" #include +#include +#include "test.hpp" // TODO: Test empty capture @@ -46,3 +47,8 @@ FIT_TEST_CASE() FIT_TEST_CHECK(fit::capture(add_member(1))(&add_member::add)(2) == 3); } +FIT_TEST_CASE() +{ + fit::capture(fit::identity)(fit::identity)(); +} +