mirror of
https://github.com/boostorg/compat.git
synced 2026-01-19 16:12:15 +00:00
Add noexcept tests for invoke_r
This commit is contained in:
@@ -79,3 +79,8 @@ 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 ;
|
||||
|
||||
52
test/invoke_r_fn_noexcept_test.cpp
Normal file
52
test/invoke_r_fn_noexcept_test.cpp
Normal 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
|
||||
99
test/invoke_r_md_noexcept_test.cpp
Normal file
99
test/invoke_r_md_noexcept_test.cpp
Normal 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();
|
||||
}
|
||||
214
test/invoke_r_mfn_noexcept_test.cpp
Normal file
214
test/invoke_r_mfn_noexcept_test.cpp
Normal 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
|
||||
70
test/invoke_r_obj_noexcept_test.cpp
Normal file
70
test/invoke_r_obj_noexcept_test.cpp
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user