mirror of
https://github.com/boostorg/lambda2.git
synced 2025-05-11 05:33:57 +00:00
Add dereference
This commit is contained in:
parent
882d13e6e4
commit
b0bcfff124
@ -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
|
||||
|
@ -19,3 +19,4 @@ run quick.cpp ;
|
||||
run lambda2_test.cpp ;
|
||||
run version.cpp ;
|
||||
run lookup_problem.cpp ;
|
||||
run dereference.cpp ;
|
||||
|
22
test/dereference.cpp
Normal file
22
test/dereference.cpp
Normal file
@ -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 <boost/lambda2.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <functional>
|
||||
|
||||
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();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user