2
0
mirror of https://github.com/boostorg/compat.git synced 2026-01-20 04:22:24 +00:00

12 Commits

Author SHA1 Message Date
Peter Dimov
2bc168926b Add is_nothrow_invocable_r 2024-04-06 22:20:25 +03:00
Peter Dimov
3025c1b929 Add is_invocable_r 2024-04-06 21:45:34 +03:00
Peter Dimov
04e6d2ce20 Remove unnecessary includes 2024-04-06 21:45:34 +03:00
Peter Dimov
8cfda56a62 Add constexpr tests for invoke_r 2024-04-06 21:45:19 +03:00
Peter Dimov
430c9b1b60 Add noexcept tests for invoke_r 2024-04-06 20:12:13 +03:00
Peter Dimov
a91461a442 Fix C++11 constexpr errors in invoke_r<void> 2024-04-06 19:45:44 +03:00
Peter Dimov
984d6b39da Add invoke_r 2024-04-06 19:03:58 +03:00
Peter Dimov
87e758f538 Update meta/libraries.json 2024-03-31 22:38:49 +03:00
Peter Dimov
ab2670f0a8 Merge pull request #9 from ashtum/resolve-mem_fn_ambiguity
Qualify call to `mem_fn`
2024-03-31 17:23:43 +03:00
Mohammad Nejati
0561949e15 Qualify call to mem_fn 2024-03-31 10:05:25 +00:00
Peter Dimov
5e88ebb1d1 Fix changelog 2024-03-30 22:24:04 +02:00
Peter Dimov
d071dfc91f Update documentation 2024-03-30 21:54:03 +02:00
31 changed files with 2181 additions and 11 deletions

View File

@@ -17,8 +17,7 @@ https://www.boost.org/LICENSE_1_0.txt
include::compat/overview.adoc[]
include::compat/changelog.adoc[]
include::compat/latch.adoc[]
include::compat/shared_lock.adoc[]
include::compat/reference.adoc[]
include::compat/copyright.adoc[]
:leveloffset: -1

58
doc/compat/bind_back.adoc Normal file
View File

@@ -0,0 +1,58 @@
////
Copyright 2024 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#bind_back]
# <boost/compat/bind_back.hpp>
:idprefix: ref_bind_back_
## Description
The header `<boost/compat/bind_back.hpp>` implements the {cpp}20 function
`std::bind_back`.
`bind_back` is a limited variant of `std::bind`. It only supports binding
the last several parameters of a function object to specific argument values.
## Example
```
struct X
{
void f(int a, int b) const noexcept;
};
int main()
{
auto fn = boost::compat::bind_back(&X::f, 1, 2);
X x;
fn(x); // calls x.f(1, 2)
}
```
## Synopsis
```
namespace boost
{
namespace compat
{
template<class F, class... A> auto bind_back(F&& f, A&&... a);
} // namespace compat
} // namespace boost
```
## bind_back
```
template<class F, class... A> auto bind_back( F&& f, A&&... a );
```
[horizontal]
Returns:;; A function object `fn` such that `fn(b...)` is equivalent to
`invoke(f, b..., a...)`.

View File

@@ -0,0 +1,58 @@
////
Copyright 2024 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#bind_front]
# <boost/compat/bind_front.hpp>
:idprefix: ref_bind_front_
## Description
The header `<boost/compat/bind_front.hpp>` implements the {cpp}20 function
`std::bind_front`.
`bind_front` is a limited variant of `std::bind`. It only supports binding
the first several parameters of a function object to specific argument values.
## Example
```
struct X
{
void f(int a, int b) const noexcept;
};
int main()
{
X x;
auto fn = boost::compat::bind_front(&X::f, &x);
fn(1, 2); // calls x.f(1, 2)
}
```
## Synopsis
```
namespace boost
{
namespace compat
{
template<class F, class... A> auto bind_front(F&& f, A&&... a);
} // namespace compat
} // namespace boost
```
## bind_front
```
template<class F, class... A> auto bind_front(F&& f, A&&... a);
```
[horizontal]
Returns:;; A function object `fn` such that `fn(b...)` is equivalent to
`invoke(f, a..., b...)`.

View File

@@ -8,6 +8,10 @@ https://www.boost.org/LICENSE_1_0.txt
# Revision History
:idprefix: changelog_
## Changes in 1.86.0
* Added `bind_front.hpp`, `bind_back.hpp`, `invoke.hpp`, `mem_fn.hpp`, `integer_sequence.hpp` and `type_traits.hpp`.
## Changes in 1.83.0
* Added `latch.hpp`, an implementation of `std::latch` (contributed by Christian Mazakas.)

View File

@@ -8,6 +8,6 @@ https://www.boost.org/LICENSE_1_0.txt
# Copyright and License
:idprefix:
This documentation is copyright 2023 Peter Dimov and contributors and is
distributed under the
This documentation is copyright 2023, 2024 Peter Dimov and
contributors and is distributed under the
http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].

View File

@@ -0,0 +1,69 @@
////
Copyright 2024 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#integer_sequence]
# <boost/compat/integer_sequence.hpp>
:idprefix: ref_integer_sequence_
## Description
The header `<boost/compat/integer_sequence.hpp>` implements the {cpp}14 utilities
`std::integer_sequence`, `std::index_sequence`, `std::make_integer_sequence`,
`std::make_index_sequence`, and `std::index_sequence_for`.
## Synopsis
```
namespace boost
{
namespace compat
{
template<class T, T... I> struct integer_sequence;
template<class T, T N> using make_integer_sequence = /*...*/;
template<std::size_t... I> using index_sequence = /*...*/;
template<std::size_t N> using make_index_sequence = /*...*/;
template<class... T> using index_sequence_for = /*...*/;
} // namespace compat
} // namespace boost
```
## integer_sequence
```
template<class T, T... I> struct integer_sequence {};
```
## make_integer_sequence
```
template<class T, T N> using make_integer_sequence = /*...*/;
```
`make_integer_sequence<T, N>` is an alias for `integer_sequence<T, 0, 1, 2, ..., N-1>`.
## index_sequence
```
template<std::size_t... I> using index_sequence = integer_sequence<std::size_t, I...>;
```
## make_index_sequence
```
template<std::size_t N> using make_index_sequence = make_integer_sequence<std::size_t, N>;
```
## index_sequence_for
```
template<class... T> using index_sequence_for = make_integer_sequence<std::size_t, sizeof...(T)>;
```

92
doc/compat/invoke.adoc Normal file
View File

@@ -0,0 +1,92 @@
////
Copyright 2024 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#invoke]
# <boost/compat/invoke.hpp>
:idprefix: ref_invoke_
## Description
The header `<boost/compat/invoke.hpp>` implements the {cpp}17 function
`std::invoke` and the associated utilities `invoke_result_t`, `is_invocable`,
and `is_nothrow_invocable`.
`invoke(f, a...)` generally returns `f(a...)`, but when `f` is a pointer to
member, it invokes it as if by returning `mem_fn(f)(a...)`. This allows
functions, function objects, and pointers to members to be treated uniformly
by components such as `bind_front`.
## Example
```
struct X
{
void f(int a, int b) const noexcept;
};
int main()
{
X x;
boost::compat::invoke(&X::f, x, 1, 2); // calls x.f(1, 2)
}
```
## Synopsis
```
namespace boost
{
namespace compat
{
template<class F, class... A> auto invoke(F&& f, A&&... a);
template<class F, class... A> using invoke_result_t = /*...*/;
template<class F, class... A> struct is_invocable;
template<class F, class... A> struct is_nothrow_invocable;
} // namespace compat
} // namespace boost
```
## invoke
```
template<class F, class... A> auto invoke(F&& f, A&&... a) noexcept(/*...*/);
```
[horizontal]
Returns:;;
* `std::forward<F>(f)(std::forward<A>(a)...)`, when `f` is not a pointer to member;
* `mem_fn(f)(std::forward<A>(a)...)`, otherwise.
Constraints:;; the return expression must be valid.
Remarks:;; The `noexcept` clause is `noexcept(noexcept(r))`, where `r` is the return expression.
## invoke_result_t
```
template<class F, class... A> using invoke_result_t =
decltype( invoke(std::declval<F>(), std::declval<A>()...) );
```
## is_invocable
```
template<class F, class... A> struct is_invocable: public /*...*/;
```
The base class of `is_invocable<F, A...>` is `std::true_type` when `invoke(std::declval<F>(), std::declval<A>()...)` is a valid expression, `std::false_type` otherwise.
## is_nothrow_invocable
```
template<class F, class... A> struct is_nothrow_invocable: public /*...*/;
```
The base class of `is_nothrow_invocable<F, A...>` is `std::false_type` when `is_invocable<F, A...>::value` is `false`, `std::integral_constant<bool, noexcept(invoke(std::declval<F>(), std::declval<A>()...))>` otherwise.

View File

@@ -6,7 +6,7 @@ https://www.boost.org/LICENSE_1_0.txt
[#latch]
# <boost/compat/latch.hpp>
:idprefix: latch_
:idprefix: ref_latch_
## Description

67
doc/compat/mem_fn.adoc Normal file
View File

@@ -0,0 +1,67 @@
////
Copyright 2024 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#mem_fn]
# <boost/compat/mem_fn.hpp>
:idprefix: ref_mem_fn_
## Description
The header `<boost/compat/mem_fn.hpp>` implements the {cpp}11 function
`std::mem_fn`.
`mem_fn(pm)`, where `pm` is a pointer to member, returns a function object
that can be used to invoke the member function, or obtain a reference to the
data member, using a function call syntax.
Even though `std::mem_fn` is {cpp}11, later standards place stricter
requirements on the returned function object (it needs to be SFINAE friendly
and propagate `noexcept` correctly.) `boost::compat::mem_fn` implements
these stricter requirements.
## Example
```
struct X
{
void f(int a, int b) const noexcept;
};
int main()
{
auto fn = boost::compat::mem_fn(&X::f);
X x;
fn(x, 1, 2); // calls x.f(1, 2)
}
```
## Synopsis
```
namespace boost
{
namespace compat
{
template<class M, class T> auto mem_fn(M T::* pm) noexcept;
} // namespace compat
} // namespace boost
```
## mem_fn
```
template<class M, class T> auto mem_fn(M T::* pm) noexcept;
```
[horizontal]
Returns:;; A function object `fn` such that:
* `fn(x, a...)` is equivalent to `(x.*pm)(a...)`, when `M` is a function type and the type of `X` is `T` or derived from `T`;
* `fn(x, a...)` is equivalent to `((*x).*pm)(a...)`, when `M` is a function type and the type of `X` is not `T` or derived from `T`;
* `fn(x)` is equivalent to `x.*pm`, when `M` is an object type and the type of `X` is `T` or derived from `T`;
* `fn(x)` is equivalent to `(*x).*pm`, when `M` is an object type and the type of `X` is not `T` or derived from `T`.

14
doc/compat/reference.adoc Normal file
View File

@@ -0,0 +1,14 @@
////
Copyright 2024 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
include::bind_back.adoc[]
include::bind_front.adoc[]
include::integer_sequence.adoc[]
include::invoke.adoc[]
include::latch.adoc[]
include::mem_fn.adoc[]
include::shared_lock.adoc[]
include::type_traits.adoc[]

View File

@@ -6,7 +6,7 @@ https://www.boost.org/LICENSE_1_0.txt
[#shared_lock]
# <boost/compat/shared_lock.hpp>
:idprefix: shared_lock_
:idprefix: ref_shared_lock_
## Description
@@ -129,7 +129,7 @@ shared_lock( mutex_type& m, std::adopt_lock_t );
[horizontal]
Preconditions:;; `m` must be held by a previous call to `m.lock_shared()` or a
successful call to `m.try_lock_shared()`.
PostConditions:;; `mutex() == std::addressof(m)` and `owns_lock() == true`.
Postconditions:;; `mutex() == std::addressof(m)` and `owns_lock() == true`.
### Copy Constructor

View File

@@ -0,0 +1,45 @@
////
Copyright 2024 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
[#type_traits]
# <boost/compat/type_traits.hpp>
:idprefix: ref_type_traits_
## Description
The header `<boost/compat/type_traits.hpp>` implements some of the
post-{cpp}11 additions to the standard header `<type_traits>`.
## Synopsis
```
#include <type_traits>
namespace boost
{
namespace compat
{
template<class T> using remove_const_t = typename std::remove_const<T>::type;
template<class T> using remove_cv_t = typename std::remove_cv<T>::type;
template<class T> using remove_reference_t = typename std::remove_reference<T>::type;
template<class T> using remove_cvref_t = remove_cv_t<remove_reference_t<T>>;
template<class T> using decay_t = typename std::decay<T>::type;
template<bool B, class T = void> using enable_if_t = typename std::enable_if<B, T>::type;
template<bool B, class T, class F> using conditional_t = typename std::conditional<B, T, F>::type;
template<class... T> using void_t = void;
} // namespace compat
} // namespace boost
```

View File

@@ -23,7 +23,7 @@ BOOST_COMPAT_RETURNS( std::forward<F>(f)(std::forward<A>(a)...) )
template<class M, class T, class... A>
constexpr auto invoke( M T::* pm, A&&... a )
BOOST_COMPAT_RETURNS( mem_fn(pm)(std::forward<A>(a)...) )
BOOST_COMPAT_RETURNS( compat::mem_fn(pm)(std::forward<A>(a)...) )
// invoke_result_t
@@ -61,6 +61,58 @@ template<class F, class... A> struct is_nothrow_invocable: conditional_t< is_inv
#endif
// invoke_r
template<class R, class F, class... A, class En = enable_if_t<
std::is_void<R>::value && is_invocable<F, A...>::value >>
constexpr R invoke_r( F&& f, A&&... a )
noexcept( noexcept( static_cast<R>( compat::invoke( std::forward<F>(f), std::forward<A>(a)... ) ) ) )
{
return static_cast<R>( compat::invoke( std::forward<F>(f), std::forward<A>(a)... ) );
}
template<class R, class F, class... A, class = void, class En = enable_if_t<
!std::is_void<R>::value && std::is_convertible< invoke_result_t<F, A...>, R >::value >>
constexpr R invoke_r( F&& f, A&&... a )
noexcept( noexcept( static_cast<R>( compat::invoke( std::forward<F>(f), std::forward<A>(a)... ) ) ) )
{
return compat::invoke( std::forward<F>(f), std::forward<A>(a)... );
}
// is_invocable_r
namespace detail {
template<class R, class F, class... A> struct is_invocable_r_: std::is_convertible< invoke_result_t<F, A...>, R > {};
} // namespace detail
template<class R, class F, class... A> struct is_invocable_r:
conditional_t< !is_invocable<F, A...>::value, std::false_type,
conditional_t< std::is_void<R>::value, std::true_type,
detail::is_invocable_r_<R, F, A...> >> {};
// is_nothrow_invocable_r
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
template<class R, class F, class... A> struct is_nothrow_invocable_r: std::false_type {};
#else
namespace detail {
template<class R, class F, class... A> struct is_nothrow_invocable_r_
{
using type = std::integral_constant<bool, noexcept( compat::invoke_r<R>( std::declval<F>(), std::declval<A>()... ) )>;
};
} // namespace detail
template<class R, class F, class... A> struct is_nothrow_invocable_r: conditional_t< is_invocable_r<R, F, A...>::value, detail::is_nothrow_invocable_r_<R, F, A...>, std::false_type >::type {};
#endif
} // namespace compat
} // namespace boost

View File

@@ -2,7 +2,8 @@
"key": "compat",
"name": "Compat",
"authors": [
"Peter Dimov"
"Peter Dimov",
"Christian Mazakas"
],
"maintainers": [
"Peter Dimov <pdimov -at- gmail.com>"

View File

@@ -74,3 +74,23 @@ compile bind_back_fn_constexpr_test.cpp ;
compile bind_back_obj_constexpr_test.cpp ;
compile bind_back_mfn_constexpr_test.cpp ;
compile bind_back_md_constexpr_test.cpp ;
run invoke_r_fn_test.cpp ;
run invoke_r_obj_test.cpp ;
run invoke_r_mfn_test.cpp ;
run invoke_r_md_test.cpp ;
run invoke_r_fn_noexcept_test.cpp ;
run invoke_r_obj_noexcept_test.cpp ;
run invoke_r_mfn_noexcept_test.cpp ;
run invoke_r_md_noexcept_test.cpp ;
compile invoke_r_fn_constexpr_test.cpp ;
compile invoke_r_obj_constexpr_test.cpp ;
compile invoke_r_mfn_constexpr_test.cpp
: <toolset>gcc-4.8:<build>no <toolset>gcc-4.9:<build>no ;
compile invoke_r_md_constexpr_test.cpp
: <toolset>gcc-4.8:<build>no <toolset>gcc-4.9:<build>no ;
run is_invocable_r_test.cpp ;
run is_nothrow_invocable_r_test.cpp ;

View File

@@ -5,7 +5,6 @@
#include <boost/compat/invoke.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <functional>
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
#define BOOST_TEST_EQ(x, y) STATIC_ASSERT((x) == (y))

View File

@@ -9,7 +9,6 @@
#include <boost/compat/invoke.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <functional>
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
#define BOOST_TEST_EQ(x, y) STATIC_ASSERT((x) == (y))

View File

@@ -0,0 +1,50 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__GNUC__) && __GNUC__ == 7
# pragma GCC diagnostic ignored "-Wnoexcept-type"
#endif
#include <boost/compat/invoke.hpp>
#include <boost/config.hpp>
#define STATIC_ASSERT(...) static_assert((__VA_ARGS__), #__VA_ARGS__)
#define BOOST_TEST_EQ(x, y) STATIC_ASSERT((x) == (y))
constexpr int f0()
{
return -1;
}
constexpr int f1( int x1 ) noexcept
{
return x1;
}
constexpr int f2( int x1, int x2 )
{
return 10*x1+x2;
}
constexpr int f3( int x1, int x2, int x3 ) noexcept
{
return 100*x1 + 10*x2 + x3;
}
int main()
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f0 ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f1, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f2, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f3, 1, 2, 3 ), 123 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( f0 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( f1, 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( f2, 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( f3, 1, 2, 3 ), true );
#endif
}

View File

@@ -0,0 +1,52 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config/pragma_message.hpp>
#if !defined(__cpp_noexcept_function_type)
BOOST_PRAGMA_MESSAGE( "Test skipped, __cpp_noexcept_function_type is not defined" )
int main() {}
#else
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test.hpp>
int f0()
{
return -1;
}
int f1( int x1 ) noexcept
{
return x1;
}
int f2( int x1, int x2 )
{
return 10*x1+x2;
}
int f3( int x1, int x2, int x3 ) noexcept
{
return 100*x1 + 10*x2 + x3;
}
int main()
{
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f0 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f1, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f2, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f3, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f0 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f1, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f2, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f3, 1, 2, 3 ) ), true );
return boost::report_errors();
}
#endif

45
test/invoke_r_fn_test.cpp Normal file
View File

@@ -0,0 +1,45 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__GNUC__) && __GNUC__ == 7
# pragma GCC diagnostic ignored "-Wnoexcept-type"
#endif
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test.hpp>
int f0()
{
return -1;
}
int f1( int x1 ) noexcept
{
return x1;
}
int f2( int x1, int x2 )
{
return 10*x1+x2;
}
int f3( int x1, int x2, int x3 ) noexcept
{
return 100*x1 + 10*x2 + x3;
}
int main()
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f0 ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f1, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f2, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f3, 1, 2, 3 ), 123 );
boost::compat::invoke_r<void>( f0 );
boost::compat::invoke_r<void>( f1, 1 );
boost::compat::invoke_r<void>( f2, 1, 2 );
boost::compat::invoke_r<void>( f3, 1, 2, 3 );
return boost::report_errors();
}

View File

@@ -0,0 +1,56 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/invoke.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#define STATIC_ASSERT(...) static_assert((__VA_ARGS__), #__VA_ARGS__)
#define BOOST_TEST_EQ(x, y) STATIC_ASSERT((x) == (y))
struct X
{
int m = -1;
};
struct Y: public X
{
};
int main()
{
{
constexpr X x = {};
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, X() ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, x ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, &x ), -1 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::m, X() ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::m, x ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::m, &x ), true );
#endif
}
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1940)
{
constexpr Y y = {};
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, Y() ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, y ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, &y ), -1 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::m, Y() ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::m, y ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::m, &y ), true );
#endif
}
#endif
}

View File

@@ -0,0 +1,99 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
struct X
{
int m = -1;
};
struct Y: public virtual X
{
};
int main()
{
{
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, X() ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, Y() ) ), true );
}
{
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, X() ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, Y() ) ), true );
}
{
X x;
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, x ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, &x ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, std::ref(x) ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, std::cref(x) ) ), true );
}
{
X x;
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, x ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, &x ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, std::ref(x) ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, std::cref(x) ) ), true );
}
{
Y y;
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, y ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, &y ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, std::ref(y) ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, std::cref(y) ) ), true );
}
{
Y y;
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, y ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, &y ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, std::ref(y) ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, std::cref(y) ) ), true );
}
{
X const x = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, x ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, &x ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, std::ref(x) ) ), true );
}
{
X const x = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, x ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, &x ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, std::ref(x) ) ), true );
}
{
Y const y = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, y ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, &y ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::m, std::ref(y) ) ), true );
}
{
Y const y = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, y ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, &y ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::m, std::ref(y) ) ), true );
}
return boost::report_errors();
}

131
test/invoke_r_md_test.cpp Normal file
View File

@@ -0,0 +1,131 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
struct X
{
int m = -1;
};
struct Y: public virtual X
{
};
int main()
{
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, X() ), -1 );
}
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, Y() ), -1 );
}
{
X x;
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, x ), -1 );
boost::compat::invoke_r<int&>( &X::m, x ) = +1;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, x ), +1 );
boost::compat::invoke_r<void>( &X::m, x );
}
{
X x;
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, &x ), -1 );
boost::compat::invoke_r<int&>( &X::m, &x ) = +1;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, &x ), +1 );
boost::compat::invoke_r<void>( &X::m, &x );
}
{
X x;
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, std::ref(x) ), -1 );
boost::compat::invoke_r<int&>( &X::m, std::ref(x) ) = +1;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, std::ref(x) ), +1 );
boost::compat::invoke_r<void>( &X::m, std::ref(x) );
}
{
X x;
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, std::cref(x) ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, std::cref(x) ), -1 );
boost::compat::invoke_r<void>( &X::m, std::cref(x) );
}
{
Y y;
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, y ), -1 );
boost::compat::invoke_r<int&>( &X::m, y ) = +1;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, y ), +1 );
boost::compat::invoke_r<void>( &X::m, y );
}
{
Y y;
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, &y ), -1 );
boost::compat::invoke_r<int&>( &X::m, &y ) = +1;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, &y ), +1 );
boost::compat::invoke_r<void>( &X::m, &y );
}
{
Y y;
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, std::ref(y) ), -1 );
boost::compat::invoke_r<int&>( &X::m, std::ref(y) ) = +1;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, std::ref(y) ), +1 );
boost::compat::invoke_r<void>( &X::m, std::ref(y) );
}
{
Y y;
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, std::cref(y) ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, std::cref(y) ), -1 );
boost::compat::invoke_r<void>( &X::m, std::cref(y) );
}
{
X const x = {};
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, x ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, x ), -1 );
boost::compat::invoke_r<void>( &X::m, x );
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, &x ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, &x ), -1 );
boost::compat::invoke_r<void>( &X::m, &x );
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, std::ref(x) ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, std::ref(x) ), -1 );
boost::compat::invoke_r<void>( &X::m, std::ref(x) );
}
{
Y const y = {};
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, y ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, y ), -1 );
boost::compat::invoke_r<void>( &X::m, y );
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, &y ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, &y ), -1 );
boost::compat::invoke_r<void>( &X::m, &y );
BOOST_TEST_EQ( boost::compat::invoke_r<int const&>( &X::m, std::ref(y) ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::m, std::ref(y) ), -1 );
boost::compat::invoke_r<void>( &X::m, std::ref(y) );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,134 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__GNUC__) && __GNUC__ == 7
# pragma GCC diagnostic ignored "-Wnoexcept-type"
#endif
#include <boost/compat/invoke.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#define STATIC_ASSERT(...) static_assert((__VA_ARGS__), #__VA_ARGS__)
#define BOOST_TEST_EQ(x, y) STATIC_ASSERT((x) == (y))
struct X
{
constexpr int f0() const
{
return -1;
}
constexpr int f1( int x1 ) const noexcept
{
return x1;
}
constexpr int f2( int x1, int x2 ) const
{
return 10*x1+x2;
}
constexpr int f3( int x1, int x2, int x3 ) const noexcept
{
return 100*x1 + 10*x2 + x3;
}
};
struct Y: public X
{
};
int main()
{
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, X() ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, X(), 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, X(), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, X(), 1, 2, 3 ), 123 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f0, X() ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f1, X(), 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f2, X(), 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f3, X(), 1, 2, 3 ), true );
#endif
}
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, Y() ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, Y(), 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, Y(), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, Y(), 1, 2, 3 ), 123 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f0, Y() ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f1, Y(), 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f2, Y(), 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f3, Y(), 1, 2, 3 ), true );
#endif
}
{
constexpr X x = {};
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, x ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, x, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, x, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, x, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, &x ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, &x, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, &x, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, &x, 1, 2, 3 ), 123 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f0, x ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f1, x, 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f2, x, 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f3, x, 1, 2, 3 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f0, &x ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f1, &x, 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f2, &x, 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f3, &x, 1, 2, 3 ), true );
#endif
}
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
{
constexpr Y y = {};
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, y ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, y, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, y, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, y, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, &y ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, &y, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, &y, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, &y, 1, 2, 3 ), 123 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f0, y ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f1, y, 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f2, y, 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f3, y, 1, 2, 3 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f0, &y ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f1, &y, 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f2, &y, 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( &X::f3, &y, 1, 2, 3 ), true );
#endif
}
#endif
}

View File

@@ -0,0 +1,214 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config/pragma_message.hpp>
#if !defined(__cpp_noexcept_function_type)
BOOST_PRAGMA_MESSAGE( "Test skipped, __cpp_noexcept_function_type is not defined" )
int main() {}
#else
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
struct X
{
int f0()
{
return -1;
}
int f1( int x1 ) noexcept
{
return x1;
}
int f2( int x1, int x2 ) const
{
return 10*x1+x2;
}
int f3( int x1, int x2, int x3 ) const noexcept
{
return 100*x1 + 10*x2 + x3;
}
};
struct Y: public virtual X
{
};
int main()
{
{
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f0, X() ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f1, X(), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, X(), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, X(), 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f0, X() ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f1, X(), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, X(), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, X(), 1, 2, 3 ) ), true );
}
{
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f0, Y() ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f1, Y(), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, Y(), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, Y(), 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f0, Y() ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f1, Y(), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, Y(), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, Y(), 1, 2, 3 ) ), true );
}
{
X x;
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f0, x ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f1, x, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, x, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, x, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f0, &x ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f1, &x, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, &x, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, &x, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f0, std::ref(x) ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f1, std::ref(x), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, std::ref(x), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, std::ref(x), 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, std::cref(x), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, std::cref(x), 1, 2, 3 ) ), true );
}
{
X x;
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f0, x ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f1, x, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, x, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, x, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f0, &x ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f1, &x, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, &x, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, &x, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f0, std::ref(x) ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f1, std::ref(x), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, std::ref(x), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, std::ref(x), 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, std::cref(x), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, std::cref(x), 1, 2, 3 ) ), true );
}
{
Y y;
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f0, y ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f1, y, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, y, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, y, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f0, &y ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f1, &y, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, &y, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, &y, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f0, std::ref(y) ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f1, std::ref(y), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, std::ref(y), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, std::ref(y), 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, std::cref(y), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, std::cref(y), 1, 2, 3 ) ), true );
}
{
Y y;
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f0, y ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f1, y, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, y, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, y, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f0, &y ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f1, &y, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, &y, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, &y, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f0, std::ref(y) ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f1, std::ref(y), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, std::ref(y), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, std::ref(y), 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, std::cref(y), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, std::cref(y), 1, 2, 3 ) ), true );
}
{
X const x = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, x, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, x, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, &x, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, &x, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, std::ref(x), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, std::ref(x), 1, 2, 3 ) ), true );
}
{
X const x = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, x, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, x, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, &x, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, &x, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, std::ref(x), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, std::ref(x), 1, 2, 3 ) ), true );
}
{
Y const y = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, y, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, y, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, &y, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, &y, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f2, std::ref(y), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( &X::f3, std::ref(y), 1, 2, 3 ) ), true );
}
{
Y const y = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, y, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, y, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, &y, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, &y, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f2, std::ref(y), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( &X::f3, std::ref(y), 1, 2, 3 ) ), true );
}
return boost::report_errors();
}
#endif

211
test/invoke_r_mfn_test.cpp Normal file
View File

@@ -0,0 +1,211 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__GNUC__) && __GNUC__ == 7
# pragma GCC diagnostic ignored "-Wnoexcept-type"
#endif
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test.hpp>
#include <functional>
struct X
{
int f0()
{
return -1;
}
int f1( int x1 ) noexcept
{
return x1;
}
int f2( int x1, int x2 ) const
{
return 10*x1+x2;
}
int f3( int x1, int x2, int x3 ) const noexcept
{
return 100*x1 + 10*x2 + x3;
}
};
struct Y: public virtual X
{
};
int main()
{
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, X() ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, X(), 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, X(), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, X(), 1, 2, 3 ), 123 );
}
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, Y() ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, Y(), 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, Y(), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, Y(), 1, 2, 3 ), 123 );
}
{
X x;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, x ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, x, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, x, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, x, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, &x ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, &x, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, &x, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, &x, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, std::ref(x) ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, std::ref(x), 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, std::ref(x), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, std::ref(x), 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, std::cref(x), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, std::cref(x), 1, 2, 3 ), 123 );
}
{
Y y;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, y ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, y, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, y, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, y, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, &y ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, &y, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, &y, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, &y, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f0, std::ref(y) ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f1, std::ref(y), 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, std::ref(y), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, std::ref(y), 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, std::cref(y), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, std::cref(y), 1, 2, 3 ), 123 );
}
{
X const x = {};
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, x, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, x, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, &x, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, &x, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, std::ref(x), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, std::ref(x), 1, 2, 3 ), 123 );
}
{
Y const y = {};
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, y, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, y, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, &y, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, &y, 1, 2, 3 ), 123 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f2, std::ref(y), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( &X::f3, std::ref(y), 1, 2, 3 ), 123 );
}
{
boost::compat::invoke_r<void>( &X::f0, X() );
boost::compat::invoke_r<void>( &X::f1, X(), 1 );
boost::compat::invoke_r<void>( &X::f2, X(), 1, 2 );
boost::compat::invoke_r<void>( &X::f3, X(), 1, 2, 3 );
}
{
boost::compat::invoke_r<void>( &X::f0, Y() );
boost::compat::invoke_r<void>( &X::f1, Y(), 1 );
boost::compat::invoke_r<void>( &X::f2, Y(), 1, 2 );
boost::compat::invoke_r<void>( &X::f3, Y(), 1, 2, 3 );
}
{
X x;
boost::compat::invoke_r<void>( &X::f0, x );
boost::compat::invoke_r<void>( &X::f1, x, 1 );
boost::compat::invoke_r<void>( &X::f2, x, 1, 2 );
boost::compat::invoke_r<void>( &X::f3, x, 1, 2, 3 );
boost::compat::invoke_r<void>( &X::f0, &x );
boost::compat::invoke_r<void>( &X::f1, &x, 1 );
boost::compat::invoke_r<void>( &X::f2, &x, 1, 2 );
boost::compat::invoke_r<void>( &X::f3, &x, 1, 2, 3 );
boost::compat::invoke_r<void>( &X::f0, std::ref(x) );
boost::compat::invoke_r<void>( &X::f1, std::ref(x), 1 );
boost::compat::invoke_r<void>( &X::f2, std::ref(x), 1, 2 );
boost::compat::invoke_r<void>( &X::f3, std::ref(x), 1, 2, 3 );
boost::compat::invoke_r<void>( &X::f2, std::cref(x), 1, 2 );
boost::compat::invoke_r<void>( &X::f3, std::cref(x), 1, 2, 3 );
}
{
Y y;
boost::compat::invoke_r<void>( &X::f0, y );
boost::compat::invoke_r<void>( &X::f1, y, 1 );
boost::compat::invoke_r<void>( &X::f2, y, 1, 2 );
boost::compat::invoke_r<void>( &X::f3, y, 1, 2, 3 );
boost::compat::invoke_r<void>( &X::f0, &y );
boost::compat::invoke_r<void>( &X::f1, &y, 1 );
boost::compat::invoke_r<void>( &X::f2, &y, 1, 2 );
boost::compat::invoke_r<void>( &X::f3, &y, 1, 2, 3 );
boost::compat::invoke_r<void>( &X::f0, std::ref(y) );
boost::compat::invoke_r<void>( &X::f1, std::ref(y), 1 );
boost::compat::invoke_r<void>( &X::f2, std::ref(y), 1, 2 );
boost::compat::invoke_r<void>( &X::f3, std::ref(y), 1, 2, 3 );
boost::compat::invoke_r<void>( &X::f2, std::cref(y), 1, 2 );
boost::compat::invoke_r<void>( &X::f3, std::cref(y), 1, 2, 3 );
}
{
X const x = {};
boost::compat::invoke_r<void>( &X::f2, x, 1, 2 );
boost::compat::invoke_r<void>( &X::f3, x, 1, 2, 3 );
boost::compat::invoke_r<void>( &X::f2, &x, 1, 2 );
boost::compat::invoke_r<void>( &X::f3, &x, 1, 2, 3 );
boost::compat::invoke_r<void>( &X::f2, std::ref(x), 1, 2 );
boost::compat::invoke_r<void>( &X::f3, std::ref(x), 1, 2, 3 );
}
{
Y const y = {};
boost::compat::invoke_r<long>( &X::f2, y, 1, 2 );
boost::compat::invoke_r<long>( &X::f3, y, 1, 2, 3 );
boost::compat::invoke_r<long>( &X::f2, &y, 1, 2 );
boost::compat::invoke_r<long>( &X::f3, &y, 1, 2, 3 );
boost::compat::invoke_r<long>( &X::f2, std::ref(y), 1, 2 );
boost::compat::invoke_r<long>( &X::f3, std::ref(y), 1, 2, 3 );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,68 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/invoke.hpp>
#define STATIC_ASSERT(...) static_assert((__VA_ARGS__), #__VA_ARGS__)
#define BOOST_TEST_EQ(x, y) STATIC_ASSERT((x) == (y))
struct F
{
constexpr int operator()() const
{
return -1;
}
constexpr int operator()( int x1 ) const noexcept
{
return x1;
}
constexpr int operator()( int x1, int x2 ) const
{
return 10*x1+x2;
}
constexpr int operator()( int x1, int x2, int x3 ) const noexcept
{
return 100*x1 + 10*x2 + x3;
}
};
int main()
{
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( F() ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( F(), 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( F(), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( F(), 1, 2, 3 ), 123 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( F() ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( F(), 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( F(), 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( F(), 1, 2, 3 ), true );
#endif
}
{
constexpr F f = {};
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f, 1, 2, 3 ), 123 );
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
STATIC_ASSERT( boost::compat::invoke_r<void>( f ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( f, 1 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( f, 1, 2 ), true );
STATIC_ASSERT( boost::compat::invoke_r<void>( f, 1, 2, 3 ), true );
#endif
}
}

View File

@@ -0,0 +1,70 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test.hpp>
struct F
{
int operator()()
{
return -1;
}
int operator()( int x1 ) noexcept
{
return x1;
}
int operator()( int x1, int x2 ) const
{
return 10*x1+x2;
}
int operator()( int x1, int x2, int x3 ) const noexcept
{
return 100*x1 + 10*x2 + x3;
}
};
int main()
{
{
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( F() ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( F(), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( F(), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( F(), 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( F() ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( F(), 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( F(), 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( F(), 1, 2, 3 ) ), true );
}
{
F f = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f, 1 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f, 1, 2, 3 ) ), true );
}
{
F const f = {};
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<long>( f, 1, 2, 3 ) ), true );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f, 1, 2 ) ), false );
BOOST_TEST_EQ( noexcept( boost::compat::invoke_r<void>( f, 1, 2, 3 ) ), true );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,80 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test.hpp>
struct F
{
int operator()()
{
return -1;
}
int operator()( int x1 ) noexcept
{
return x1;
}
int operator()( int x1, int x2 ) const
{
return 10*x1+x2;
}
int operator()( int x1, int x2, int x3 ) const noexcept
{
return 100*x1 + 10*x2 + x3;
}
};
int main()
{
{
BOOST_TEST_EQ( boost::compat::invoke_r<long>( F() ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( F(), 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( F(), 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( F(), 1, 2, 3 ), 123 );
}
{
F f;
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f ), -1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f, 1 ), 1 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f, 1, 2, 3 ), 123 );
}
{
F const f = {};
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f, 1, 2 ), 12 );
BOOST_TEST_EQ( boost::compat::invoke_r<long>( f, 1, 2, 3 ), 123 );
}
{
boost::compat::invoke_r<void>( F() );
boost::compat::invoke_r<void>( F(), 1 );
boost::compat::invoke_r<void>( F(), 1, 2 );
boost::compat::invoke_r<void>( F(), 1, 2, 3 );
}
{
F f;
boost::compat::invoke_r<void>( f );
boost::compat::invoke_r<void>( f, 1 );
boost::compat::invoke_r<void>( f, 1, 2 );
boost::compat::invoke_r<void>( f, 1, 2, 3 );
}
{
F const f = {};
boost::compat::invoke_r<void>( f, 1, 2 );
boost::compat::invoke_r<void>( f, 1, 2, 3 );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,195 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct F
{
void operator()()
{
}
char operator()( char x1 ) noexcept
{
return x1;
}
int operator()( int x1, int x2 ) const
{
return 10*x1+x2;
}
double operator()( float x1, float x2, float x3 ) const noexcept
{
return 100*x1 + 10*x2 + x3;
}
};
struct X
{
};
int main()
{
using boost::compat::is_invocable_r;
// nonfunction
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, int, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, int, int, int> ));
// function reference
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, void(&)()> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, char(&)(int), char> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int(&)(int, int), int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, double(&)(double, double, double), float, float, float> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, void(&)()> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, char(&)(int), char> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int(&)(int, int), int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, double(&)(double, double, double), float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, void(&)()> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, char(&)(int), char> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int(&)(int, int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, double(&)(double, double, double), float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, void(&)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, char(&)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, char(&)(int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, void(&)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, char(&)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, char(&)(int), int, int> ));
// function pointer
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, void(*)()> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, char(*)(int), char> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int(*)(int, int), int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, double(*)(double, double, double), float, float, float> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, void(*)()> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, char(*)(int), char> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int(*)(int, int), int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, double(*)(double, double, double), float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, void(*)()> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, char(*)(int), char> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int(*)(int, int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, double(*)(double, double, double), float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, void(*)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, char(*)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, char(*)(int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, void(*)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, char(*)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, char(*)(int), int, int> ));
// object
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, F> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, F, char> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, F, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, F, float, float, float> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, F> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, F, char> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, F, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, F, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, F> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, F, char> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, F, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, F, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, F, int, int, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, F const> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, F, int, int, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, F const> ));
// member function pointer
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, void(X::*)(), X> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, char(X::*)(int), X, char> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int(X::*)(int, int), X, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, double(X::*)(double, double, double), X, float, float, float> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, void(X::*)(), X> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, char(X::*)(int), X, char> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int(X::*)(int, int), X, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, double(X::*)(double, double, double), X, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, void(X::*)(), X> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, char(X::*)(int), X, char> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int(X::*)(int, int), X, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, double(X::*)(double, double, double), X, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, void(X::*)()> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, void(X::*)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, void(X::*)(), X, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, char(X::*)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, char(X::*)(int), int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, char(X::*)(int), X> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, char(X::*)(int), X, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, void(X::*)()> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, void(X::*)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, void(X::*)(), X, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, char(X::*)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, char(X::*)(int), int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, char(X::*)(int), X> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, char(X::*)(int), X, int, int> ));
// member data pointer
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int X::*, X> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int X::*, X const> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int X::*, X&> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int X::*, X const&> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int X::*, X*> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<long, int X::*, X const*> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int X::*, X> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int X::*, X const> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int X::*, X&> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int X::*, X const&> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int X::*, X*> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<void, int X::*, X const*> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int X::*, X> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int X::*, X const> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int X::*, X&> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int X::*, X const&> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int X::*, X*> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<X, int X::*, X const*> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<int&, int X::*, X> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<int&, int X::*, X const> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<int&, int X::*, X&> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<int&, int X::*, X const&> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<int&, int X::*, X*> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<int&, int X::*, X const*> ));
BOOST_TEST_TRAIT_TRUE(( is_invocable_r<int&&, int X::*, X> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, int X::*> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, int X::*, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<long, int X::*, X, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, int X::*> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, int X::*, int> ));
BOOST_TEST_TRAIT_FALSE(( is_invocable_r<void, int X::*, X, int> ));
return boost::report_errors();
}

View File

@@ -0,0 +1,288 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/compat/invoke.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
struct F
{
void operator()()
{
}
char operator()( char x1 ) noexcept
{
return x1;
}
int operator()( int x1, int x2 ) const
{
return 10*x1+x2;
}
double operator()( float x1, float x2, float x3 ) const noexcept
{
return 100*x1 + 10*x2 + x3;
}
};
struct X
{
};
struct Y
{
Y( int );
Y( double ) noexcept;
};
int main()
{
using boost::compat::is_nothrow_invocable_r;
// nonfunction
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int, int, int> ));
// function reference
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(&)()> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(&)(int), char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int(&)(int, int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, double(&)(double, double, double), float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, void(&)()> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(&)(int), char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int(&)(int, int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, double(&)(double, double, double), float, float, float> ));
#if defined(__cpp_noexcept_function_type)
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(&)() noexcept> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, char(&)(int) noexcept, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int(&)(int, int) noexcept, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, double(&)(double, double, double) noexcept, float, float, float> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, void(&)() noexcept> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, char(&)(int) noexcept, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int(&)(int, int) noexcept, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, double(&)(double, double, double) noexcept, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, void(&)() noexcept> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, char(&)(int) noexcept, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int(&)(int, int) noexcept, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, double(&)(double, double, double) noexcept, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, void(&)() noexcept> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, char(&)(int) noexcept, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int(&)(int, int) noexcept, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double(&)(double, double, double) noexcept, float, float, float> ));
#endif
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(&)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(&)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(&)(int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, void(&)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(&)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(&)(int), int, int> ));
// function pointer
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(*)()> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(*)(int), char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int(*)(int, int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, double(*)(double, double, double), float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, void(*)()> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(*)(int), char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int(*)(int, int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, double(*)(double, double, double), float, float, float> ));
#if defined(__cpp_noexcept_function_type)
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(*)() noexcept> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, char(*)(int) noexcept, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int(*)(int, int) noexcept, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, double(*)(double, double, double) noexcept, float, float, float> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, void(*)() noexcept> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, char(*)(int) noexcept, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int(*)(int, int) noexcept, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, double(*)(double, double, double) noexcept, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, void(*)() noexcept> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, char(*)(int) noexcept, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int(*)(int, int) noexcept, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, double(*)(double, double, double) noexcept, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, void(*)() noexcept> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, char(*)(int) noexcept, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int(*)(int, int) noexcept, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double(*)(double, double, double) noexcept, float, float, float> ));
#endif
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(*)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(*)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(*)(int), int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, void(*)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(*)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(*)(int), int, int> ));
// object
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, F> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, F, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, F> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, F, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, F> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, F, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, F> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, F, int, int> ));
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, F, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, F, float, float, float> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, F, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, F, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, F, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, F, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, F, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, F, float, float, float> ));
#endif
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, F, int, int, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, F const> ));
// member function pointer
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(X::*)(), X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(X::*)(int), X, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int(X::*)(int, int), X, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, double(X::*)(double, double, double), X, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, void(X::*)(), X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(X::*)(int), X, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int(X::*)(int, int), X, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, double(X::*)(double, double, double), X, float, float, float> ));
#if defined(__cpp_noexcept_function_type)
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(X::*)() noexcept, X> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, char(X::*)(int) noexcept, X, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int(X::*)(int, int) noexcept, X, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, double(X::*)(double, double, double) noexcept, X, float, float, float> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, void(X::*)() noexcept, X> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, char(X::*)(int) noexcept, X, char> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int(X::*)(int, int) noexcept, X, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, double(X::*)(double, double, double) noexcept, X, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, void(X::*)() noexcept, X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, char(X::*)(int) noexcept, X, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int(X::*)(int, int) noexcept, X, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, double(X::*)(double, double, double) noexcept, X, float, float, float> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, void(X::*)() noexcept, X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, char(X::*)(int) noexcept, X, char> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int(X::*)(int, int) noexcept, X, int, int> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double(X::*)(double, double, double) noexcept, X, float, float, float> ));
#endif
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(X::*)()> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(X::*)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, void(X::*)(), X, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(X::*)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(X::*)(int), int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(X::*)(int), X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, char(X::*)(int), X, int, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, void(X::*)()> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, void(X::*)(), int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, void(X::*)(), X, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(X::*)(int)> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(X::*)(int), int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(X::*)(int), X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, char(X::*)(int), X, int, int> ));
// member data pointer
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int X::*, X> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int X::*, X const> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int X::*, X&> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int X::*, X const&> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int X::*, X*> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<long, int X::*, X const*> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int X::*, X> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int X::*, X const> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int X::*, X&> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int X::*, X const&> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int X::*, X*> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<void, int X::*, X const*> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int X::*, X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int X::*, X const> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int X::*, X&> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int X::*, X const&> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int X::*, X*> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<X, int X::*, X const*> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int X::*, X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int X::*, X const> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int X::*, X&> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int X::*, X const&> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int X::*, X*> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<Y, int X::*, X const*> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double X::*, X> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double X::*, X const> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double X::*, X&> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double X::*, X const&> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double X::*, X*> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<Y, double X::*, X const*> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<int&, int X::*, X> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<int&, int X::*, X const> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<int&, int X::*, X&> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<int&, int X::*, X const&> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<int&, int X::*, X*> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<int&, int X::*, X const*> ));
BOOST_TEST_TRAIT_TRUE(( is_nothrow_invocable_r<int&&, int X::*, X> ));
#endif
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int X::*> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int X::*, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<long, int X::*, X, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int X::*> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int X::*, int> ));
BOOST_TEST_TRAIT_FALSE(( is_nothrow_invocable_r<void, int X::*, X, int> ));
return boost::report_errors();
}