Skip to content

Commit 8ceb48b

Browse files
committed
Stylistic changes to mp_lambda
1 parent 23fd166 commit 8ceb48b

File tree

2 files changed

+51
-47
lines changed

2 files changed

+51
-47
lines changed

include/boost/mp11/lambda.hpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include <boost/mp11/detail/config.hpp>
1212

1313
#if BOOST_MP11_WORKAROUND(BOOST_MP11_MSVC, <= 1800)
14+
1415
// mp_lambda not supported due to compiler limitations
16+
1517
#else
1618

1719
#include <boost/mp11/bind.hpp>
@@ -73,14 +75,14 @@ BOOST_MP11_SPECIALIZE_LAMBDA_IMPL(pointer, T*)
7375
// GCC < 7 fails with template<class U> using make = U&;
7476
template<class T> struct lambda_impl<T&>
7577
{
76-
template<class U> using make = typename std::add_lvalue_reference<U>::type;
77-
using type = mp_bind<make, mp_lambda<T>>;
78+
template<class U> using make = typename std::add_lvalue_reference<U>::type;
79+
using type = mp_bind<make, mp_lambda<T>>;
7880
};
7981

8082
template<class T> struct lambda_impl<T&&>
8183
{
82-
template<class U> using make = typename std::add_rvalue_reference<U>::type;
83-
using type = mp_bind<make, mp_lambda<T>>;
84+
template<class U> using make = typename std::add_rvalue_reference<U>::type;
85+
using type = mp_bind<make, mp_lambda<T>>;
8486
};
8587

8688
// [dcl.array]
@@ -135,9 +137,9 @@ template<class R, class C, class... T> struct lambda_impl<R (C::*)(T..., ...) qu
135137
mp_lambda<R>, mp_lambda<C>, mp_lambda<T>...>; \
136138
};
137139

138-
#define BOOST_MP11_EMPTY()
140+
#define BOOST_MP11_LAMBDA_EMPTY()
139141

140-
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(no_qualifier, BOOST_MP11_EMPTY())
142+
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(no_qualifier, BOOST_MP11_LAMBDA_EMPTY())
141143
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(const, const)
142144
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(volatile, volatile)
143145
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(const_volatile, const volatile)
@@ -151,6 +153,7 @@ BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(volatile_rvalue_ref, volatile&&)
151153
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(const_volatile_rvalue_ref, const volatile&&)
152154

153155
#if (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L
156+
154157
// P0012R1: exception specification as part of the type system
155158
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(noexcept, noexcept)
156159
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(const_noexcept, const noexcept)
@@ -164,15 +167,16 @@ BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(rvalue_ref_noexcept, && noexcept
164167
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(const_rvalue_ref_noexcept, const&& noexcept)
165168
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(volatile_rvalue_ref_noexcept, volatile&& noexcept)
166169
BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR(const_volatile_rvalue_ref_noexcept, const volatile&& noexcept)
170+
167171
#endif // P0012R1
168172

169-
#undef BOOST_MP11_EMPTY
173+
#undef BOOST_MP11_LAMBDA_EMPTY
170174
#undef BOOST_MP11_SPECIALIZE_LAMBDA_IMPL_FCT_AND_MFPTR
171175

172176
// [dcl.mptr] (data members)
173-
template<class T, class C> struct lambda_impl<T (C::*)>
177+
template<class T, class C> struct lambda_impl<T C::*>
174178
{
175-
template<class U, class D> using make = U (D::*);
179+
template<class U, class D> using make = U D::*;
176180
using type = mp_bind<make, mp_lambda<T>, mp_lambda<C>>;
177181
};
178182

test/mp_lambda.cpp

+38-38
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#if BOOST_MP11_WORKAROUND(BOOST_MP11_MSVC, <= 1800)
1313

14-
#pragma message("Test skipped because mp_lambda is not supported")
14+
#pragma message("Test skipped because BOOST_MP11_MSVC <= 1800")
1515
int main() {}
1616

1717
#else
@@ -54,27 +54,27 @@ int main()
5454
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1>::fn<int>, int>));
5555
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_2>::fn<void, int>, int>));
5656

57-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<const _1>::fn<int>, CONST int>));
58-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<volatile _1>::fn<int>, VOLATILE int>));
59-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<const volatile _2>::fn<void, int>, CONST VOLATILE int>));
57+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 const>::fn<int>, int CONST>));
58+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 volatile>::fn<int>, int VOLATILE>));
59+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_2 const volatile>::fn<void, int>, int CONST VOLATILE>));
6060

6161
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1*>::fn<int>, int*>));
62-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<const _1*>::fn<int>, CONST int*>));
63-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<const _1* const>::fn<int>, CONST int* CONST>));
64-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<const _1*>::fn<void>, CONST void*>));
62+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 const*>::fn<int>, int CONST*>));
63+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 const* const>::fn<int>, int CONST* CONST>));
64+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 const*>::fn<void>, void CONST*>));
6565

6666
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1&>::fn<int>, int&>));
67-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<volatile _1*&>::fn<int>, VOLATILE int*&>));
67+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 volatile *&>::fn<int>, int VOLATILE *&>));
6868
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1&&>::fn<int>, int&&>));
69-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<volatile _1*&&>::fn<int>, VOLATILE int*&&>));
69+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 volatile *&&>::fn<int>, int VOLATILE *&&>));
7070

7171
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1[]>::fn<int>, int[]>));
7272
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1[5]>::fn<int>, int[5]>));
7373
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1*[][5]>::fn<int>, int*[][5]>));
7474

7575
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2, _3)>::fn<int, char, double>, int(char, double)>));
7676
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<int(_2)>::fn<void, char>, int(char)>));
77-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(void)>::fn<void>, void()>));
77+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1()>::fn<void>, void()>));
7878
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2, _2*)>::fn<int, char>, int(char, char*)>));
7979
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(*[])(_2)>::fn<int, char>, int(*[])(char)>));
8080
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2, ...)>::fn<int, char>, int(char, ...)>));
@@ -93,18 +93,18 @@ int main()
9393
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) volatile&&>::fn<int, char>, int(char) volatile&&>));
9494
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const volatile&&>::fn<int, char>, int(char) const volatile&&>));
9595

96-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) noexcept>::fn<int, char>, int(char) noexcept >));
97-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const noexcept>::fn<int, char>, int(char) const noexcept >));
98-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) volatile noexcept>::fn<int, char>, int(char) volatile noexcept >));
99-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const volatile noexcept>::fn<int, char>, int(char) const volatile noexcept >));
100-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2)& noexcept>::fn<int, char>, int(char)& noexcept >));
101-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const& noexcept>::fn<int, char>, int(char) const& noexcept >));
102-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) volatile& noexcept>::fn<int, char>, int(char) volatile& noexcept >));
103-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const volatile& noexcept>::fn<int, char>, int(char) const volatile& noexcept >));
104-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2)&& noexcept>::fn<int, char>, int(char)&& noexcept >));
105-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const&& noexcept>::fn<int, char>, int(char) const&& noexcept >));
106-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) volatile&& noexcept>::fn<int, char>, int(char) volatile&& noexcept >));
107-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const volatile&& noexcept>::fn<int, char>, int(char) const volatile&& noexcept >));
96+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) noexcept>::fn<int, char>, int(char) noexcept>));
97+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const noexcept>::fn<int, char>, int(char) const noexcept>));
98+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) volatile noexcept>::fn<int, char>, int(char) volatile noexcept>));
99+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const volatile noexcept>::fn<int, char>, int(char) const volatile noexcept>));
100+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2)& noexcept>::fn<int, char>, int(char)& noexcept>));
101+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const& noexcept>::fn<int, char>, int(char) const& noexcept>));
102+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) volatile& noexcept>::fn<int, char>, int(char) volatile& noexcept>));
103+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const volatile& noexcept>::fn<int, char>, int(char) const volatile& noexcept>));
104+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2)&& noexcept>::fn<int, char>, int(char)&& noexcept>));
105+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const&& noexcept>::fn<int, char>, int(char) const&& noexcept>));
106+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) volatile&& noexcept>::fn<int, char>, int(char) volatile&& noexcept>));
107+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1(_2) const volatile&& noexcept>::fn<int, char>, int(char) const volatile&& noexcept>));
108108

109109
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2)>::fn<int, char, X>, int (X::*)(char)>));
110110
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const>::fn<int, char, X>, int (X::*)(char) const>));
@@ -119,28 +119,28 @@ int main()
119119
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) volatile&&>::fn<int, char, X>, int (X::*)(char) volatile&&>));
120120
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const volatile&&>::fn<int, char, X>, int (X::*)(char) const volatile&&>));
121121

122-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) noexcept>::fn<int, char, X>, int (X::*)(char) noexcept >));
123-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const noexcept>::fn<int, char, X>, int (X::*)(char) const noexcept >));
124-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) volatile noexcept>::fn<int, char, X>, int (X::*)(char) volatile noexcept >));
125-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const volatile noexcept>::fn<int, char, X>, int (X::*)(char) const volatile noexcept >));
126-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2)& noexcept>::fn<int, char, X>, int (X::*)(char)& noexcept >));
127-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const& noexcept>::fn<int, char, X>, int (X::*)(char) const& noexcept >));
128-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) volatile& noexcept>::fn<int, char, X>, int (X::*)(char) volatile& noexcept >));
129-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const volatile& noexcept>::fn<int, char, X>, int (X::*)(char) const volatile& noexcept >));
130-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2)&& noexcept>::fn<int, char, X>, int (X::*)(char)&& noexcept >));
131-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const&& noexcept>::fn<int, char, X>, int (X::*)(char) const&& noexcept >));
132-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) volatile&& noexcept>::fn<int, char, X>, int (X::*)(char) volatile&& noexcept >));
133-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const volatile&& noexcept>::fn<int, char, X>, int (X::*)(char) const volatile&& noexcept >));
134-
135-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_2::*)>::fn<int, X>, int (X::*)>));
122+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) noexcept>::fn<int, char, X>, int (X::*)(char) noexcept>));
123+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const noexcept>::fn<int, char, X>, int (X::*)(char) const noexcept>));
124+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) volatile noexcept>::fn<int, char, X>, int (X::*)(char) volatile noexcept>));
125+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const volatile noexcept>::fn<int, char, X>, int (X::*)(char) const volatile noexcept>));
126+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2)& noexcept>::fn<int, char, X>, int (X::*)(char)& noexcept>));
127+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const& noexcept>::fn<int, char, X>, int (X::*)(char) const& noexcept>));
128+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) volatile& noexcept>::fn<int, char, X>, int (X::*)(char) volatile& noexcept>));
129+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const volatile& noexcept>::fn<int, char, X>, int (X::*)(char) const volatile& noexcept>));
130+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2)&& noexcept>::fn<int, char, X>, int (X::*)(char)&& noexcept>));
131+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const&& noexcept>::fn<int, char, X>, int (X::*)(char) const&& noexcept>));
132+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) volatile&& noexcept>::fn<int, char, X>, int (X::*)(char) volatile&& noexcept>));
133+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 (_3::*)(_2) const volatile&& noexcept>::fn<int, char, X>, int (X::*)(char) const volatile&& noexcept>));
134+
135+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<_1 _2::*>::fn<int, X>, int X::*>));
136136

137137
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::pair<_1, _2>>::fn<char, int>, std::pair<char, int>>));
138138
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::pair<_2, _1>>::fn<char, int>, std::pair<int, char>>));
139-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::pair<const _1*, _2&>>::fn<char, int>, std::pair<CONST char*, int&>>));
139+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::pair<_1 const*, _2&>>::fn<char, int>, std::pair<char CONST*, int&>>));
140140

141141
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::tuple<_1, _2>>::fn<char, int>, std::tuple<char, int>>));
142142
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::tuple<_2, _1>*>::fn<X, int>, std::tuple<int, X>*>));
143-
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::tuple<const _1*, _2&>*>::fn<char, int>, std::tuple<CONST char*, int&>*>));
143+
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::tuple<_1 const*, _2&>*>::fn<char, int>, std::tuple<char CONST*, int&>*>));
144144
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::tuple<_3, std::pair<_2, _1>>>::fn<char, int, double>, std::tuple<double, std::pair<int, char>>>));
145145

146146
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_lambda<std::tuple<_1, _2>>::fn<_2, _1>, std::tuple<_2, _1>>));

0 commit comments

Comments
 (0)