diff options
Diffstat (limited to 'src/boost/libs/hof/test/issue8.cpp')
-rw-r--r-- | src/boost/libs/hof/test/issue8.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/boost/libs/hof/test/issue8.cpp b/src/boost/libs/hof/test/issue8.cpp new file mode 100644 index 00000000..08acb9a7 --- /dev/null +++ b/src/boost/libs/hof/test/issue8.cpp @@ -0,0 +1,48 @@ +/*============================================================================= + Copyright (c) 2017 Paul Fultz II + issue8.cpp + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#include "test.hpp" +#include <vector> +#include <boost/hof/pipable.hpp> +#include <boost/hof/placeholders.hpp> +#include <algorithm> + + +struct filter_fn +{ + template<class Input, class P> + Input operator()(Input input, P pred) const + { + Input output(input.size()); + output.erase( + ::std::copy_if( + ::std::begin(input), + ::std::end(input), + ::std::begin(output), + pred + ), + ::std::end(output) + ); + return output; + } +}; + +static constexpr boost::hof::pipable_adaptor<filter_fn> filter = {}; + +BOOST_HOF_TEST_CASE() +{ + std::vector<int> data; + for(int i=0;i<6;i++) + { + data.push_back(i); + } + std::vector<int> r1 = data | filter(boost::hof::_1 > 1); + BOOST_HOF_TEST_CHECK(r1.size() == 4); + + std::vector<int> r2 = filter(data, boost::hof::_1 > 1); + BOOST_HOF_TEST_CHECK(r2.size() == 4); +} |