diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/boost/libs/lambda2 | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/lambda2')
-rw-r--r-- | src/boost/libs/lambda2/CMakeLists.txt | 20 | ||||
-rw-r--r-- | src/boost/libs/lambda2/README.md | 21 | ||||
-rw-r--r-- | src/boost/libs/lambda2/index.html | 15 | ||||
-rw-r--r-- | src/boost/libs/lambda2/meta/libraries.json | 14 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/Jamfile | 29 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/compound.cpp | 32 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/dereference.cpp | 22 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/increment.cpp | 34 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/lambda2_test.cpp | 69 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/lookup_problem.cpp | 24 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/placeholders.cpp | 48 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/project.cpp | 79 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/quick.cpp | 15 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/stream_extract.cpp | 42 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/stream_insert.cpp | 38 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/subscript.cpp | 27 | ||||
-rw-r--r-- | src/boost/libs/lambda2/test/version.cpp | 13 |
17 files changed, 542 insertions, 0 deletions
diff --git a/src/boost/libs/lambda2/CMakeLists.txt b/src/boost/libs/lambda2/CMakeLists.txt new file mode 100644 index 000000000..00b455c7d --- /dev/null +++ b/src/boost/libs/lambda2/CMakeLists.txt @@ -0,0 +1,20 @@ +# Generated by `boostdep --cmake lambda2` +# Copyright 2020 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_lambda2 VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) + +add_library(boost_lambda2 INTERFACE) +add_library(Boost::lambda2 ALIAS boost_lambda2) + +target_include_directories(boost_lambda2 INTERFACE include) + +if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") + + add_subdirectory(test) + +endif() + diff --git a/src/boost/libs/lambda2/README.md b/src/boost/libs/lambda2/README.md new file mode 100644 index 000000000..ce436d3f5 --- /dev/null +++ b/src/boost/libs/lambda2/README.md @@ -0,0 +1,21 @@ +# Lambda2 + +This is an implementation of the simple C++14 lambda library +described in [this post](https://pdimov.github.io/blog/2020/07/22/a-c14-lambda-library/). + +It has no dependencies and consists of a [single header](include/boost/lambda2/lambda2.hpp). + +See [the documentation](https://www.boost.org/libs/lambda2/) for more information. + +## Supported Compilers + +* g++ 5 or later with `-std=c++14` or above +* clang++ 3.9 or later with `-std=c++14` or above +* Visual Studio 2015, 2017, 2019 + +Tested on [Github Actions](https://github.com/boostorg/lambda2/actions) and +[Appveyor](https://ci.appveyor.com/project/pdimov/lambda2). + +## License + +Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt). diff --git a/src/boost/libs/lambda2/index.html b/src/boost/libs/lambda2/index.html new file mode 100644 index 000000000..995feecd4 --- /dev/null +++ b/src/boost/libs/lambda2/index.html @@ -0,0 +1,15 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/html/lambda2.html"> +</head> +<body> +Automatic redirection failed, please go to +<a href="doc/html/lambda2.html">doc/html/lambda2.html</a>. +</body> +</html> +<!-- + Copyright Beman Dawes, 2001 + 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 +--> diff --git a/src/boost/libs/lambda2/meta/libraries.json b/src/boost/libs/lambda2/meta/libraries.json new file mode 100644 index 000000000..db6b29d64 --- /dev/null +++ b/src/boost/libs/lambda2/meta/libraries.json @@ -0,0 +1,14 @@ +{ + "key": "lambda2", + "name": "Lambda2", + "authors": [ + "Peter Dimov" + ], + "maintainers": [ + "Peter Dimov <pdimov -at- gmail.com>" + ], + "description": "A C++14 lambda library.", + "category": [ + "Function-objects" + ] +} diff --git a/src/boost/libs/lambda2/test/Jamfile b/src/boost/libs/lambda2/test/Jamfile new file mode 100644 index 000000000..a21728b7e --- /dev/null +++ b/src/boost/libs/lambda2/test/Jamfile @@ -0,0 +1,29 @@ +# Copyright 2020 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +import testing ; +import ../../config/checks/config : requires ; + +project : requirements + + <warnings>extra + + [ requires cxx14_return_type_deduction ] + + <toolset>msvc:<warnings-as-errors>on + <toolset>clang:<warnings-as-errors>on + <toolset>gcc:<warnings-as-errors>on ; + +run quick.cpp ; +run lambda2_test.cpp ; +run version.cpp ; +run lookup_problem.cpp ; +run dereference.cpp ; +run placeholders.cpp ; +run increment.cpp ; +run subscript.cpp ; +run compound.cpp ; +run stream_insert.cpp ; +run stream_extract.cpp ; +run project.cpp ; diff --git a/src/boost/libs/lambda2/test/compound.cpp b/src/boost/libs/lambda2/test/compound.cpp new file mode 100644 index 000000000..3e63ef7fe --- /dev/null +++ b/src/boost/libs/lambda2/test/compound.cpp @@ -0,0 +1,32 @@ +// 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> + +#define TEST_COMPOUND(Op) \ + BOOST_TEST_EQ( (_1 Op 1)(x1), y1 Op 1 ); \ + BOOST_TEST_EQ( (_1 Op _2)(x1, x2), y1 Op y2 ); \ + BOOST_TEST_EQ( ((_1 Op _2) Op _3)(x1, x2, x3), (y1 Op y2) Op y3 ); + +int main() +{ + using namespace boost::lambda2; + + int x1 = 1, x2 = 2, x3 = 3, y1 = 1, y2 = 2, y3 = 3; + + TEST_COMPOUND(+=) + TEST_COMPOUND(-=) + TEST_COMPOUND(*=) + TEST_COMPOUND(/=) + TEST_COMPOUND(%=) + TEST_COMPOUND(&=) + TEST_COMPOUND(|=) + TEST_COMPOUND(^=) + TEST_COMPOUND(<<=) + TEST_COMPOUND(>>=) + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/dereference.cpp b/src/boost/libs/lambda2/test/dereference.cpp new file mode 100644 index 000000000..aae8e4db4 --- /dev/null +++ b/src/boost/libs/lambda2/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 <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(); +} diff --git a/src/boost/libs/lambda2/test/increment.cpp b/src/boost/libs/lambda2/test/increment.cpp new file mode 100644 index 000000000..d36b55eaf --- /dev/null +++ b/src/boost/libs/lambda2/test/increment.cpp @@ -0,0 +1,34 @@ +// 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 x1 = 1, x2 = 2, y1 = 1, y2 = 2; + + BOOST_TEST_EQ( (_1++)(x1), y1++ ); + BOOST_TEST_EQ( (++_1)(x1), ++y1 ); + + BOOST_TEST_EQ( (_1--)(x1), y1-- ); + BOOST_TEST_EQ( (--_1)(x1), --y1 ); + + BOOST_TEST_EQ( (_1++ + _2++)(x1, x2), y1++ + y2++ ); + BOOST_TEST_EQ( (++_1 + ++_2)(x1, x2), ++y1 + ++y2 ); + + BOOST_TEST_EQ( (_1-- + _2--)(x1, x2), y1-- + y2-- ); + BOOST_TEST_EQ( (--_1 + --_2)(x1, x2), --y1 + --y2 ); + + BOOST_TEST_EQ( std::bind(_1 + _2, _1++, _2++)(x1, x2), y1++ + y2++ ); + BOOST_TEST_EQ( std::bind(_1 + _2, ++_1, ++_2)(x1, x2), ++y1 + ++y2 ); + + BOOST_TEST_EQ( std::bind(_1 + _2, _1--, _2--)(x1, x2), y1-- + y2-- ); + BOOST_TEST_EQ( std::bind(_1 + _2, --_1, --_2)(x1, x2), --y1 + --y2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/lambda2_test.cpp b/src/boost/libs/lambda2/test/lambda2_test.cpp new file mode 100644 index 000000000..5e1d81ea3 --- /dev/null +++ b/src/boost/libs/lambda2/test/lambda2_test.cpp @@ -0,0 +1,69 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#if defined(_MSC_VER) && _MSC_VER == 1900 +# pragma warning(disable: 4552) // '<<': operator has no effect; expected operator with side-effect +#endif + +#include <boost/lambda2.hpp> +#include <boost/core/lightweight_test.hpp> + +#define TEST_UNARY(Op) \ + BOOST_TEST_EQ( (Op _1)( 0 ), Op 0 ); \ + BOOST_TEST_EQ( (Op _1)( 1 ), Op 1 ); \ + BOOST_TEST_EQ( (Op _1)( 5 ), Op 5 ); \ + BOOST_TEST_EQ( (Op (Op _1))( 5 ), Op (Op 5) ); \ + BOOST_TEST_EQ( ((Op _1) + (Op _2))( 1, 2 ), (Op 1) + (Op 2) ); \ + BOOST_TEST_EQ( ((Op _1) && (Op _2))( 1, 2 ), (Op 1) && (Op 2) ); + +#define TEST_BINARY(Op) \ + BOOST_TEST_EQ( (_1 Op _2)( 0, 1 ), 0 Op 1 ); \ + BOOST_TEST_EQ( (_1 Op _2)( 3, 5 ), 3 Op 5 ); \ + BOOST_TEST_EQ( (_1 Op 2)( 1, 2 ), 1 Op 2 ); \ + BOOST_TEST_EQ( (1 Op _2)( 1, 2 ), 1 Op 2 ); \ + BOOST_TEST_EQ( ((_1 Op _2) + (_3 Op _4))( 1, 2, 3, 4 ), (1 Op 2) + (3 Op 4) ); + +int main() +{ + using namespace boost::lambda2; + + TEST_BINARY(+) + TEST_BINARY(-) + TEST_BINARY(*) + TEST_BINARY(/) + TEST_BINARY(%) + TEST_UNARY(-) + + TEST_BINARY(==) + TEST_BINARY(!=) + TEST_BINARY(>) + TEST_BINARY(<) + TEST_BINARY(>=) + TEST_BINARY(<=) + + TEST_BINARY(&&) + TEST_BINARY(||) + TEST_UNARY(!) + + TEST_BINARY(&) + TEST_BINARY(|) + TEST_BINARY(^) + TEST_UNARY(~) + +#if defined(_MSC_VER) && _MSC_VER == 1900 && !defined(_DEBUG) + + // prevents crash in TEST_BINARY(/) + // no idea why + + BOOST_TEST_EQ( (_1 / _2)( 0, 1 ), 0 / 1 ); + +#endif + + TEST_BINARY(<<) + TEST_BINARY(>>) + + TEST_UNARY(+) + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/lookup_problem.cpp b/src/boost/libs/lambda2/test/lookup_problem.cpp new file mode 100644 index 000000000..0bafc41a0 --- /dev/null +++ b/src/boost/libs/lambda2/test/lookup_problem.cpp @@ -0,0 +1,24 @@ +// 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> + +namespace N +{ + struct Irrelevant {}; + void operator+( Irrelevant, Irrelevant ); + + int plus_one( int i ) + { + using namespace boost::lambda2; + return (_1 + 1)( i ); + } +} + +int main() +{ + BOOST_TEST_EQ( N::plus_one( 4 ), 5 ); + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/placeholders.cpp b/src/boost/libs/lambda2/test/placeholders.cpp new file mode 100644 index 000000000..61f8a27c9 --- /dev/null +++ b/src/boost/libs/lambda2/test/placeholders.cpp @@ -0,0 +1,48 @@ +// 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 f( int x ) +{ + return x; +} + +int main() +{ + using namespace boost::lambda2; + + BOOST_TEST_EQ( std::bind(f, _1)( 1 ), 1 ); + BOOST_TEST_EQ( std::bind(f, _2)( 1, 2 ), 2 ); + BOOST_TEST_EQ( std::bind(f, _3)( 1, 2, 3 ), 3 ); + BOOST_TEST_EQ( std::bind(f, _4)( 1, 2, 3, 4 ), 4 ); + BOOST_TEST_EQ( std::bind(f, _5)( 1, 2, 3, 4, 5 ), 5 ); + BOOST_TEST_EQ( std::bind(f, _6)( 1, 2, 3, 4, 5, 6 ), 6 ); + BOOST_TEST_EQ( std::bind(f, _7)( 1, 2, 3, 4, 5, 6, 7 ), 7 ); + BOOST_TEST_EQ( std::bind(f, _8)( 1, 2, 3, 4, 5, 6, 7, 8 ), 8 ); + BOOST_TEST_EQ( std::bind(f, _9)( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 9 ); + + BOOST_TEST_EQ( _1( 1 ), 1 ); + BOOST_TEST_EQ( _2( 1, 2 ), 2 ); + BOOST_TEST_EQ( _3( 1, 2, 3 ), 3 ); + BOOST_TEST_EQ( _4( 1, 2, 3, 4 ), 4 ); + BOOST_TEST_EQ( _5( 1, 2, 3, 4, 5 ), 5 ); + BOOST_TEST_EQ( _6( 1, 2, 3, 4, 5, 6 ), 6 ); + BOOST_TEST_EQ( _7( 1, 2, 3, 4, 5, 6, 7 ), 7 ); + BOOST_TEST_EQ( _8( 1, 2, 3, 4, 5, 6, 7, 8 ), 8 ); + BOOST_TEST_EQ( _9( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 9 ); + + BOOST_TEST_EQ( _1( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 1 ); + BOOST_TEST_EQ( _2( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 2 ); + BOOST_TEST_EQ( _3( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 3 ); + BOOST_TEST_EQ( _4( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 4 ); + BOOST_TEST_EQ( _5( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 5 ); + BOOST_TEST_EQ( _6( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 6 ); + BOOST_TEST_EQ( _7( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 7 ); + BOOST_TEST_EQ( _8( 1, 2, 3, 4, 5, 6, 7, 8, 9 ), 8 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/project.cpp b/src/boost/libs/lambda2/test/project.cpp new file mode 100644 index 000000000..4971e387f --- /dev/null +++ b/src/boost/libs/lambda2/test/project.cpp @@ -0,0 +1,79 @@ +// 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 <utility> + +struct X +{ + int m1; + int m2; + + int f1() const + { + return m1; + } + + int& f2() + { + return m2; + } +}; + +int main() +{ + using namespace boost::lambda2; + + { + X const x{ 1, 2 }; + + BOOST_TEST_EQ( (_1->*&X::m1)( x ), 1 ); + BOOST_TEST_EQ( (_1->*&X::m2)( x ), 2 ); + BOOST_TEST_EQ( (_1->*&X::f1)( x ), 1 ); + } + + { + X x{ 0, 0 }; + + BOOST_TEST_EQ( (_1->*&X::m1)( x ), 0 ); + BOOST_TEST_EQ( (_1->*&X::m2)( x ), 0 ); + BOOST_TEST_EQ( (_1->*&X::f1)( x ), 0 ); + BOOST_TEST_EQ( (_1->*&X::f2)( x ), 0 ); + +#if defined(_LIBCPP_VERSION) + + // https://bugs.llvm.org/show_bug.cgi?id=51753 + using std::placeholders::_1; + +#endif + + BOOST_TEST_EQ( (_1->*&X::m1 += 1)( x ), 1 ); + BOOST_TEST_EQ( (_1->*&X::m2 += 2)( x ), 2 ); + + BOOST_TEST_EQ( (_1->*&X::f1)( x ), 1 ); + BOOST_TEST_EQ( (_1->*&X::f2)( x ), 2 ); + + BOOST_TEST_EQ( (_1->*&X::f2 += 3)( x ), 5 ); + } + + { + std::pair<int, int> const x( 1, 2 ); + + BOOST_TEST_EQ( (_1->*&std::pair<int, int>::first)( x ), 1 ); + BOOST_TEST_EQ( (_1->*&std::pair<int, int>::second)( x ), 2 ); + +#if defined(_LIBCPP_VERSION) + + // https://bugs.llvm.org/show_bug.cgi?id=51753 + using std::placeholders::_1; + +#endif + + BOOST_TEST_EQ( (_1->*first)( x ), 1 ); + BOOST_TEST_EQ( (_1->*second)( x ), 2 ); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/quick.cpp b/src/boost/libs/lambda2/test/quick.cpp new file mode 100644 index 000000000..32742cfc4 --- /dev/null +++ b/src/boost/libs/lambda2/test/quick.cpp @@ -0,0 +1,15 @@ +// Copyright 2020 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> + +int main() +{ + using namespace boost::lambda2; + + BOOST_TEST_EQ( (_1 + _2 * _3)( 1, 2, 3), 1 + 2 * 3 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/stream_extract.cpp b/src/boost/libs/lambda2/test/stream_extract.cpp new file mode 100644 index 000000000..4cfc0cf67 --- /dev/null +++ b/src/boost/libs/lambda2/test/stream_extract.cpp @@ -0,0 +1,42 @@ +// 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 <sstream> +#include <string> + +template<class T> T from_string_1( std::string const& s ) +{ + using namespace boost::lambda2; + + std::istringstream is( s ); + + T t{}; + + ( std::ref( is ) >> _1 )( t ); + + return t; +} + +template<class T> T from_string_2( std::string const& s ) +{ + using namespace boost::lambda2; + + std::istringstream is( s ); + + T t{}; + + ( is >> _1 )( t ); + + return t; +} + +int main() +{ + BOOST_TEST_EQ( from_string_1<int>( "123" ), 123 ); + BOOST_TEST_EQ( from_string_2<int>( "456" ), 456 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/stream_insert.cpp b/src/boost/libs/lambda2/test/stream_insert.cpp new file mode 100644 index 000000000..b8410aedf --- /dev/null +++ b/src/boost/libs/lambda2/test/stream_insert.cpp @@ -0,0 +1,38 @@ +// 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 <sstream> +#include <string> + +template<class T> std::string to_string_1( T const& t ) +{ + using namespace boost::lambda2; + + std::ostringstream os; + + ( std::ref( os ) << _1 )( t ); + + return os.str(); +} + +template<class T> std::string to_string_2( T const& t ) +{ + using namespace boost::lambda2; + + std::ostringstream os; + + ( os << _1 )( t ); + + return os.str(); +} + +int main() +{ + BOOST_TEST_EQ( to_string_1( 123 ), "123" ); + BOOST_TEST_EQ( to_string_2( 456 ), "456" ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/subscript.cpp b/src/boost/libs/lambda2/test/subscript.cpp new file mode 100644 index 000000000..b20eff2ab --- /dev/null +++ b/src/boost/libs/lambda2/test/subscript.cpp @@ -0,0 +1,27 @@ +// 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, 4 }; + + BOOST_TEST_EQ( _1[0](x), x[0] ); + BOOST_TEST_EQ( _1[_2](x, 1), x[1] ); + BOOST_TEST_EQ( (_1[_2] + _3[_4])(x, 2, x, 3), x[2] + x[3] ); + BOOST_TEST_EQ( std::bind(_1 + _2, _1[_2], _3[_4])(x, 2, x, 3), x[2] + x[3] ); + + _1[0](x) = 7; + BOOST_TEST_EQ( x[0], 7 ); + + _1[_2](x, 1) = 8; + BOOST_TEST_EQ( x[1], 8 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/lambda2/test/version.cpp b/src/boost/libs/lambda2/test/version.cpp new file mode 100644 index 000000000..d4c8de579 --- /dev/null +++ b/src/boost/libs/lambda2/test/version.cpp @@ -0,0 +1,13 @@ +// 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/version.hpp> +#include <boost/core/lightweight_test.hpp> + +int main() +{ + BOOST_TEST_EQ( BOOST_LAMBDA2_VERSION, BOOST_VERSION ); + return boost::report_errors(); +} |