diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-07-09 15:01:41 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-07-16 14:31:13 +0200 |
commit | b8bcaa92d0fe795c2da2a70a33390274ab03d0cd (patch) | |
tree | 734dd213c0d6df84f16967f19a37855a47f0726a /compat | |
parent | 08933e46ed419cb40e0d9740d35161d014b0d48c (diff) |
compat/functional: fix template
Diffstat (limited to 'compat')
-rw-r--r-- | compat/functional.hpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/compat/functional.hpp b/compat/functional.hpp index 893fe1a0..fcf6393c 100644 --- a/compat/functional.hpp +++ b/compat/functional.hpp @@ -3,9 +3,10 @@ #include <algorithm> #include <iterator> #include <type_traits> +#include <vector> template<typename t> -using remove_qualifiers = std::remove_reference_t<std::remove_cv_t<t>>; +using remove_qualifiers = std::remove_cv_t<std::remove_reference_t<t>>; namespace functools { @@ -52,10 +53,11 @@ struct constant final template<typename seq_, typename F> auto map(F&& fun, const seq_& seq) { - using seq_type = remove_qualifiers<seq_>; + using value_type = remove_qualifiers<typename std::iterator_traits<decltype(std::begin(seq))>::value_type>; + using ret_type = remove_qualifiers<decltype(fun(std::declval<value_type>()))>; - seq_type ret; - std::back_insert_iterator<seq_type> it = std::back_inserter(ret); + std::vector<ret_type> ret; + auto it = std::back_inserter(ret); for (const auto& elt : seq) it = fun(elt); @@ -69,8 +71,8 @@ auto remove_if_not(F&& fun, const seq_& seq) using namespace functools; using seq_type = remove_qualifiers<seq_>; - using value_type = typename std::iterator_traits<decltype(std::begin(std::declval<seq_>()))>::value_type; - using fun_ret_type = decltype(fun(std::declval<const value_type&>())); + using value_type = remove_qualifiers<typename std::iterator_traits<decltype(std::begin(seq))>::value_type>; + using fun_ret_type = decltype(fun(std::declval<value_type>())); static_assert(std::is_convertible<fun_ret_type, bool>::value, "must return bool"); seq_type ret; |