diff --git a/include/boost/lambda2/lambda2.hpp b/include/boost/lambda2/lambda2.hpp index ce7a735..56e85b1 100644 --- a/include/boost/lambda2/lambda2.hpp +++ b/include/boost/lambda2/lambda2.hpp @@ -90,6 +90,7 @@ BOOST_LAMBDA2_BINARY_FN(<<, left_shift) BOOST_LAMBDA2_BINARY_FN(>>, right_shift) BOOST_LAMBDA2_PREFIX_FN(+, unary_plus) +BOOST_LAMBDA2_PREFIX_FN(*, dereference) // operators @@ -151,6 +152,7 @@ BOOST_LAMBDA2_BINARY_LAMBDA(<<, lambda2_detail::left_shift) BOOST_LAMBDA2_BINARY_LAMBDA(>>, lambda2_detail::right_shift) BOOST_LAMBDA2_UNARY_LAMBDA(+, lambda2_detail::unary_plus) +BOOST_LAMBDA2_UNARY_LAMBDA(*, lambda2_detail::dereference) } // namespace lambda2 } // namespace boost diff --git a/test/Jamfile b/test/Jamfile index 5f8f799..dfe9cbd 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -19,3 +19,4 @@ run quick.cpp ; run lambda2_test.cpp ; run version.cpp ; run lookup_problem.cpp ; +run dereference.cpp ; diff --git a/test/dereference.cpp b/test/dereference.cpp new file mode 100644 index 0000000..aae8e4d --- /dev/null +++ b/test/dereference.cpp @@ -0,0 +1,22 @@ +// Copyright 2021 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +int main() +{ + using namespace boost::lambda2; + + int x[] = { 1, 2, 3 }; + + BOOST_TEST_EQ( (*_1)(x+0), *(x+0) ); + BOOST_TEST_EQ( (*_1)(x+1), *(x+1) ); + BOOST_TEST_EQ( (*_1 + *_2)(x+0, x+1), *(x+0) + *(x+1) ); + BOOST_TEST_EQ( (*_1 + *_2 + *_3)(x+0, x+1, x+2), *(x+0) + *(x+1) + *(x+2) ); + BOOST_TEST_EQ( std::bind(_1 + _2 + _3, *_1, *_2, *_3)(x+0, x+1, x+2), *(x+0) + *(x+1) + *(x+2) ); + + return boost::report_errors(); +}