mirror of
https://github.com/boostorg/lambda2.git
synced 2026-01-19 16:22:20 +00:00
Compare commits
13 Commits
feature/op
...
boost-1.80
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd1a3e4543 | ||
|
|
8c6c1166c4 | ||
|
|
c618d6902b | ||
|
|
ae42ebda76 | ||
|
|
3ccd5c251b | ||
|
|
132db3b09a | ||
|
|
253aef863f | ||
|
|
a593616a98 | ||
|
|
2ff3fef3d1 | ||
|
|
0572e42219 | ||
|
|
7c39436198 | ||
|
|
f8b3099259 | ||
|
|
a666ac4fb6 |
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
@@ -139,14 +139,22 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.1
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2016
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,latest"
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: "14"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
@@ -183,4 +191,4 @@ jobs:
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||
|
||||
@@ -9,7 +9,10 @@ Peter Dimov
|
||||
:toc: left
|
||||
:toclevels: 4
|
||||
:idprefix:
|
||||
:listing-caption: Code Example
|
||||
:docinfo: private-footer
|
||||
:source-highlighter: rouge
|
||||
:source-language: c++
|
||||
|
||||
:leveloffset: +1
|
||||
|
||||
|
||||
@@ -12,3 +12,5 @@ https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
* Added special cases in `operator<<` and `operator>>` when
|
||||
the first argument is a stream, to allow `std::cout << _1`.
|
||||
* Added `operator\->*`.
|
||||
* Added `first`, `second`.
|
||||
|
||||
@@ -21,14 +21,14 @@ namespace lambda2 {
|
||||
template<int I> struct lambda2_arg;
|
||||
|
||||
inline constexpr lambda2_arg<1> _1{};
|
||||
inline constexpr lambda2_arg<1> _2{};
|
||||
inline constexpr lambda2_arg<1> _3{};
|
||||
inline constexpr lambda2_arg<1> _4{};
|
||||
inline constexpr lambda2_arg<1> _5{};
|
||||
inline constexpr lambda2_arg<1> _6{};
|
||||
inline constexpr lambda2_arg<1> _7{};
|
||||
inline constexpr lambda2_arg<1> _8{};
|
||||
inline constexpr lambda2_arg<1> _9{};
|
||||
inline constexpr lambda2_arg<2> _2{};
|
||||
inline constexpr lambda2_arg<3> _3{};
|
||||
inline constexpr lambda2_arg<4> _4{};
|
||||
inline constexpr lambda2_arg<5> _5{};
|
||||
inline constexpr lambda2_arg<6> _6{};
|
||||
inline constexpr lambda2_arg<7> _7{};
|
||||
inline constexpr lambda2_arg<8> _8{};
|
||||
inline constexpr lambda2_arg<9> _9{};
|
||||
|
||||
// arithmetic operators
|
||||
|
||||
@@ -90,6 +90,11 @@ template<class A, class B> auto operator>>=( A && a, B && b );
|
||||
|
||||
template<class A, class B> auto operator->*( A && a, B && b );
|
||||
|
||||
// projections
|
||||
|
||||
inline constexpr /unspecified/ first{};
|
||||
inline constexpr /unspecified/ second{};
|
||||
|
||||
} // namespace lambda2
|
||||
} // namespace boost
|
||||
```
|
||||
@@ -405,3 +410,26 @@ Returns: :: `std::bind( std::forward<B>(b), std::forward<A>(a) );`
|
||||
Notes: :: This operator is intended to be used with "projection" function
|
||||
objects such as member pointers or member functions taking zero arguments,
|
||||
as in `_1\->*&X::m` or `_1\->*&X::f`.
|
||||
|
||||
### Projections
|
||||
|
||||
```
|
||||
inline constexpr /unspecified/ first{};
|
||||
```
|
||||
|
||||
A function object such that `first(x)` returns `std::get<0>(x)`.
|
||||
|
||||
```
|
||||
inline constexpr /unspecified/ second{};
|
||||
```
|
||||
|
||||
A function object such that `second(x)` returns `std::get<1>(x)`.
|
||||
|
||||
.Using first and second to print out a map
|
||||
```
|
||||
void print( std::map<int, std::string> const & m )
|
||||
{
|
||||
using namespace boost::lambda2;
|
||||
std::for_each( m.begin(), m.end(), std::cout << _1->*first << ": " << _1->*second << '\n' );
|
||||
}
|
||||
```
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
// Same format as BOOST_VERSION:
|
||||
// major * 100000 + minor * 100 + patch
|
||||
#define BOOST_LAMBDA2_VERSION 107800
|
||||
#define BOOST_LAMBDA2_VERSION 108000
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -32,6 +32,14 @@ struct subscript
|
||||
}
|
||||
};
|
||||
|
||||
template<int I> struct get
|
||||
{
|
||||
template<class T> decltype(auto) operator()( T&& t ) const
|
||||
{
|
||||
return std::get<I>( std::forward<T>(t) );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace lambda2_detail
|
||||
|
||||
// placeholders
|
||||
@@ -65,6 +73,11 @@ BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<7> _7{};
|
||||
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<8> _8{};
|
||||
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<9> _9{};
|
||||
|
||||
// first, second
|
||||
|
||||
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_detail::get<0> first{};
|
||||
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_detail::get<1> second{};
|
||||
|
||||
#undef BOOST_LAMBDA2_INLINE_VAR
|
||||
|
||||
} // namespace lambda2
|
||||
|
||||
@@ -63,6 +63,16 @@ int main()
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user