mirror of
https://github.com/boostorg/compat.git
synced 2026-01-19 16:12:15 +00:00
Compare commits
18 Commits
feature/in
...
feature/bi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28e71552eb | ||
|
|
10ad6ab592 | ||
|
|
39ddb40a47 | ||
|
|
928f2d7255 | ||
|
|
5a5db4a74f | ||
|
|
acd8c12e91 | ||
|
|
710ea6a904 | ||
|
|
a09b9b2c5a | ||
|
|
758b0c2ef9 | ||
|
|
4ea967b756 | ||
|
|
d745abe3a3 | ||
|
|
fa9180b234 | ||
|
|
abcc654046 | ||
|
|
b6deff5638 | ||
|
|
90e76cb4f4 | ||
|
|
c290c03ea3 | ||
|
|
bba8d5f101 | ||
|
|
56b776fc29 |
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -22,6 +22,11 @@ jobs:
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:16.04
|
||||
install: g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-latest
|
||||
@@ -194,7 +199,7 @@ jobs:
|
||||
mkdir -p libs/$LIBRARY
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
python3 tools/boostdep/depinst/depinst.py $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ target_include_directories(boost_compat INTERFACE include)
|
||||
target_link_libraries(boost_compat
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::throw_exception
|
||||
)
|
||||
|
||||
target_compile_features(boost_compat INTERFACE cxx_std_11)
|
||||
|
||||
72
include/boost/compat/bind_front.hpp
Normal file
72
include/boost/compat/bind_front.hpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef BOOST_COMPAT_BIND_FRONT_HPP_INCLUDED
|
||||
#define BOOST_COMPAT_BIND_FRONT_HPP_INCLUDED
|
||||
|
||||
// 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/compat/type_traits.hpp>
|
||||
#include <boost/compat/integer_sequence.hpp>
|
||||
#include <boost/compat/detail/returns.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace compat {
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4100) // 'a': unreferenced formal parameter
|
||||
#endif
|
||||
|
||||
template<class F, class A, class... B, std::size_t... I>
|
||||
static constexpr auto invoke_bind_front_( F&& f, A&& a, index_sequence<I...>, B&&... b )
|
||||
BOOST_COMPAT_RETURNS( compat::invoke( std::forward<F>(f), std::get<I>( std::forward<A>(a) )..., std::forward<B>(b)... ) )
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template<class F, class... A> class bind_front_
|
||||
{
|
||||
private:
|
||||
|
||||
F f_;
|
||||
std::tuple<A...> a_;
|
||||
|
||||
public:
|
||||
|
||||
template<class F2, class... A2>
|
||||
constexpr bind_front_( F2&& f2, A2&&... a2 ): f_( std::forward<F2>(f2) ), a_( std::forward<A2>(a2)... ) {}
|
||||
|
||||
public:
|
||||
|
||||
template<class... B> BOOST_CXX14_CONSTEXPR auto operator()( B&&... b ) &
|
||||
BOOST_COMPAT_RETURNS( detail::invoke_bind_front_( f_, a_, make_index_sequence<sizeof...(A)>(), std::forward<B>(b)... ) )
|
||||
|
||||
template<class... B> constexpr auto operator()( B&&... b ) const &
|
||||
BOOST_COMPAT_RETURNS( detail::invoke_bind_front_( f_, a_, make_index_sequence<sizeof...(A)>(), std::forward<B>(b)... ) )
|
||||
|
||||
template<class... B> BOOST_CXX14_CONSTEXPR auto operator()( B&&... b ) &&
|
||||
BOOST_COMPAT_RETURNS( detail::invoke_bind_front_( std::move(f_), std::move(a_), make_index_sequence<sizeof...(A)>(), std::forward<B>(b)... ) )
|
||||
|
||||
template<class... B> constexpr auto operator()( B&&... b ) const &&
|
||||
BOOST_COMPAT_RETURNS( detail::invoke_bind_front_( std::move(f_), std::move(a_), make_index_sequence<sizeof...(A)>(), std::forward<B>(b)... ) )
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class F, class... A> constexpr auto bind_front( F&& f, A&&... a ) -> detail::bind_front_< decay_t<F>, decay_t<A>... >
|
||||
{
|
||||
return { std::forward<F>(f), std::forward<A>(a)... };
|
||||
}
|
||||
|
||||
} // namespace compat
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_COMPAT_BIND_FRONT_HPP_INCLUDED
|
||||
120
include/boost/compat/integer_sequence.hpp
Normal file
120
include/boost/compat/integer_sequence.hpp
Normal file
@@ -0,0 +1,120 @@
|
||||
#ifndef BOOST_COMPAT_INTEGER_SEQUENCE_HPP_INCLUDED
|
||||
#define BOOST_COMPAT_INTEGER_SEQUENCE_HPP_INCLUDED
|
||||
|
||||
// Copyright 2015, 2017, 2019 Peter Dimov.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(_MSC_VER) || defined(__GNUC__)
|
||||
# pragma push_macro( "I" )
|
||||
# undef I
|
||||
#endif
|
||||
|
||||
#if defined(__has_builtin)
|
||||
# if __has_builtin(__make_integer_seq)
|
||||
# define BOOST_COMPAT_HAS_MAKE_INTEGER_SEQ
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace compat
|
||||
{
|
||||
|
||||
// integer_sequence
|
||||
template<class T, T... I> struct integer_sequence
|
||||
{
|
||||
};
|
||||
|
||||
#if defined(BOOST_COMPAT_HAS_MAKE_INTEGER_SEQ)
|
||||
|
||||
template<class T, T N> using make_integer_sequence = __make_integer_seq<integer_sequence, T, N>;
|
||||
|
||||
#else
|
||||
|
||||
// detail::make_integer_sequence_impl
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// iseq_if_c
|
||||
template<bool C, class T, class E> struct iseq_if_c_impl;
|
||||
|
||||
template<class T, class E> struct iseq_if_c_impl<true, T, E>
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<class T, class E> struct iseq_if_c_impl<false, T, E>
|
||||
{
|
||||
using type = E;
|
||||
};
|
||||
|
||||
template<bool C, class T, class E> using iseq_if_c = typename iseq_if_c_impl<C, T, E>::type;
|
||||
|
||||
// iseq_identity
|
||||
template<class T> struct iseq_identity
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<class S1, class S2> struct append_integer_sequence;
|
||||
|
||||
template<class T, T... I, T... J> struct append_integer_sequence<integer_sequence<T, I...>, integer_sequence<T, J...>>
|
||||
{
|
||||
using type = integer_sequence< T, I..., ( J + sizeof...(I) )... >;
|
||||
};
|
||||
|
||||
template<class T, T N> struct make_integer_sequence_impl;
|
||||
|
||||
template<class T, T N> struct make_integer_sequence_impl_
|
||||
{
|
||||
private:
|
||||
|
||||
static_assert( N >= 0, "make_integer_sequence<T, N>: N must not be negative" );
|
||||
|
||||
static T const M = N / 2;
|
||||
static T const R = N % 2;
|
||||
|
||||
using S1 = typename make_integer_sequence_impl<T, M>::type;
|
||||
using S2 = typename append_integer_sequence<S1, S1>::type;
|
||||
using S3 = typename make_integer_sequence_impl<T, R>::type;
|
||||
using S4 = typename append_integer_sequence<S2, S3>::type;
|
||||
|
||||
public:
|
||||
|
||||
using type = S4;
|
||||
};
|
||||
|
||||
template<class T, T N> struct make_integer_sequence_impl: iseq_if_c<N == 0, iseq_identity<integer_sequence<T>>, iseq_if_c<N == 1, iseq_identity<integer_sequence<T, 0>>, make_integer_sequence_impl_<T, N> > >
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// make_integer_sequence
|
||||
template<class T, T N> using make_integer_sequence = typename detail::make_integer_sequence_impl<T, N>::type;
|
||||
|
||||
#endif // defined(BOOST_COMPAT_HAS_MAKE_INTEGER_SEQ)
|
||||
|
||||
// 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)>;
|
||||
|
||||
} // namespace compat
|
||||
} // namespace boost
|
||||
|
||||
#if defined(_MSC_VER) || defined(__GNUC__)
|
||||
# pragma pop_macro( "I" )
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_COMPAT_INTEGER_SEQUENCE_HPP_INCLUDED
|
||||
@@ -15,6 +15,8 @@ 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;
|
||||
|
||||
16
test/Jamfile
16
test/Jamfile
@@ -45,10 +45,22 @@ run invoke_md_noexcept_test.cpp ;
|
||||
compile invoke_fn_constexpr_test.cpp ;
|
||||
compile invoke_obj_constexpr_test.cpp ;
|
||||
compile invoke_mfn_constexpr_test.cpp
|
||||
: <toolset>gcc-4.8:<build>no ;
|
||||
: <toolset>gcc-4.8:<build>no <toolset>gcc-4.9:<build>no ;
|
||||
compile invoke_md_constexpr_test.cpp
|
||||
: <toolset>gcc-4.8:<build>no ;
|
||||
: <toolset>gcc-4.8:<build>no <toolset>gcc-4.9:<build>no ;
|
||||
|
||||
run invoke_result_test.cpp ;
|
||||
run is_invocable_test.cpp ;
|
||||
run is_nothrow_invocable_test.cpp ;
|
||||
|
||||
run bind_front_fn_test.cpp ;
|
||||
run bind_front_obj_test.cpp ;
|
||||
run bind_front_mfn_test.cpp ;
|
||||
run bind_front_md_test.cpp ;
|
||||
|
||||
compile bind_front_fn_constexpr_test.cpp ;
|
||||
compile bind_front_obj_constexpr_test.cpp ;
|
||||
compile bind_front_mfn_constexpr_test.cpp ;
|
||||
compile bind_front_md_constexpr_test.cpp ;
|
||||
|
||||
run integer_sequence_test.cpp ;
|
||||
|
||||
60
test/bind_front_fn_constexpr_test.cpp
Normal file
60
test/bind_front_fn_constexpr_test.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
// 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/bind_front.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#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::bind_front( f0 )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f1 )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f2 )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f3 )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f1, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f2, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f3, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f2, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f3, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f3, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
#endif
|
||||
57
test/bind_front_fn_test.cpp
Normal file
57
test/bind_front_fn_test.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// 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/bind_front.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <memory>
|
||||
|
||||
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 g( std::unique_ptr<int> p, std::unique_ptr<int> q )
|
||||
{
|
||||
return 10 * *p + *q;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f0 )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f1 )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f2 )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f3 )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f1, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f2, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f3, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f2, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f3, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( f3, 1, 2, 3 )(), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( g, std::unique_ptr<int>( new int(1) ) )( std::unique_ptr<int>( new int(2) ) ), 12 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
58
test/bind_front_md_constexpr_test.cpp
Normal file
58
test/bind_front_md_constexpr_test.cpp
Normal 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
|
||||
|
||||
#include <boost/compat/bind_front.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#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()
|
||||
{
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, X() )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr X x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, x )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &x )(), -1 );
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, >= 1920 && BOOST_MSVC < 1940)
|
||||
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, Y() )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr Y y = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, y )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &y )(), -1 );
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
101
test/bind_front_md_test.cpp
Normal file
101
test/bind_front_md_test.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/compat/bind_front.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::bind_front( &X::m, X() )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, Y() )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, x )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &x )(), -1 );
|
||||
boost::compat::bind_front( &X::m, &x )() = +1;
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &x )(), +1 );
|
||||
}
|
||||
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, std::ref(x) )(), -1 );
|
||||
boost::compat::bind_front( &X::m, std::ref(x) )() = +1;
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, std::ref(x) )(), +1 );
|
||||
}
|
||||
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, std::cref(x) )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, y )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &y )(), -1 );
|
||||
boost::compat::bind_front( &X::m, &y )() = +1;
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &y )(), +1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, std::ref(y) )(), -1 );
|
||||
boost::compat::bind_front( &X::m, std::ref(y) )() = +1;
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, std::ref(y) )(), +1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, std::cref(y) )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
X const x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, x )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &x )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, std::ref(x) )(), -1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y const y = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, y )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, &y )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::m, std::ref(y) )(), -1 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
167
test/bind_front_mfn_constexpr_test.cpp
Normal file
167
test/bind_front_mfn_constexpr_test.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
// 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/bind_front.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
#define BOOST_TEST_EQ(x, y) STATIC_ASSERT((x) == (y))
|
||||
|
||||
struct X
|
||||
{
|
||||
constexpr int f0()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
constexpr int f1( int x1 ) 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::bind_front( &X::f0 )( X() ), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1 )( X(), 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( X(), 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( X(), 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, X() )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, X() )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, X() )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, X() )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, X(), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, X(), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, X(), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, X(), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, X(), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, X(), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, Y() )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, Y() )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, Y() )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y() )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, Y() )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, Y() )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, Y() )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y() )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, Y(), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, Y(), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y(), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, Y(), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y(), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y(), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr X x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr X x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( &x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( &x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr Y x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr Y x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( &x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( &x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
378
test/bind_front_mfn_test.cpp
Normal file
378
test/bind_front_mfn_test.cpp
Normal file
@@ -0,0 +1,378 @@
|
||||
// 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/bind_front.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
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::bind_front( &X::f0 )( X() ), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1 )( X(), 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( X(), 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( X(), 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, X() )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, X() )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, X() )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, X() )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, X(), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, X(), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, X(), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, X(), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, X(), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, X(), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, Y() )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, Y() )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, Y() )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y() )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, Y() )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, Y() )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, Y() )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y() )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, Y(), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, Y(), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y(), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, Y(), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y(), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, Y(), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0 )( x ), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1 )( x, 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, x )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, x )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0 )( &x ), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1 )( &x, 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( &x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( &x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, &x )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, &x )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, &x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0 )( std::ref(x) ), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1 )( std::ref(x), 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( std::ref(x), 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( std::ref(x), 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, std::ref(x) )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, std::ref(x) )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x) )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x) )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, std::ref(x), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
X x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( std::cref(x), 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( std::cref(x), 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::cref(x) )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::cref(x) )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::cref(x), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::cref(x), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::cref(x), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::cref(x), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::cref(x), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
Y x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0 )( x ), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1 )( x, 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, x )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, x )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
Y x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0 )( &x ), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1 )( &x, 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( &x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( &x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, &x )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, &x )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, &x, 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
Y x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0 )( std::ref(x) ), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1 )( std::ref(x), 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( std::ref(x), 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( std::ref(x), 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f0, std::ref(x) )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, std::ref(x) )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x) )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x) )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f1, std::ref(x), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
Y x;
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( std::cref(x), 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( std::cref(x), 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::cref(x) )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::cref(x) )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::cref(x), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::cref(x), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::cref(x), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::cref(x), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::cref(x), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
X const x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
X const x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( &x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( &x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
X const x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( std::ref(x), 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( std::ref(x), 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x) )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x) )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
Y const x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
Y const x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( &x, 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( &x, 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, &x, 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, &x, 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
Y const x = {};
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2 )( std::ref(x), 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3 )( std::ref(x), 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x) )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x) )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f2, std::ref(x), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::ref(x), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_ptr<X> px( new X );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::move(px), 1 )( 2, 3 ), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_ptr<Y> px( new Y );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( &X::f3, std::move(px), 1 )( 2, 3 ), 123 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
96
test/bind_front_obj_constexpr_test.cpp
Normal file
96
test/bind_front_obj_constexpr_test.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/compat/bind_front.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||
#define BOOST_TEST_EQ(x, y) STATIC_ASSERT((x) == (y))
|
||||
|
||||
struct F1
|
||||
{
|
||||
constexpr int operator()()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
constexpr int operator()( int x1 ) 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;
|
||||
}
|
||||
};
|
||||
|
||||
struct F2
|
||||
{
|
||||
constexpr int operator()( int x1, int x2 ) &
|
||||
{
|
||||
return 100*x1 + 10*x2 + 1;
|
||||
}
|
||||
|
||||
constexpr int operator()( int x1, int x2 ) const &
|
||||
{
|
||||
return 100*x1 + 10*x2 + 2;
|
||||
}
|
||||
constexpr int operator()( int x1, int x2 ) &&
|
||||
{
|
||||
return 100*x1 + 10*x2 + 3;
|
||||
}
|
||||
constexpr int operator()( int x1, int x2 ) const &&
|
||||
{
|
||||
return 100*x1 + 10*x2 + 4;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1() )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1() )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1() )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1() )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F2(), 9 )( 8 ), 983 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr auto fn = boost::compat::bind_front( F2(), 9 );
|
||||
BOOST_TEST_EQ( fn( 8 ), 982 );
|
||||
}
|
||||
|
||||
{
|
||||
constexpr auto fn = boost::compat::bind_front( F2(), 9 );
|
||||
BOOST_TEST_EQ( std::move( fn )( 8 ), 984 );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
101
test/bind_front_obj_test.cpp
Normal file
101
test/bind_front_obj_test.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/compat/bind_front.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
struct F1
|
||||
{
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
struct F2
|
||||
{
|
||||
int operator()( int x1, int x2 ) &
|
||||
{
|
||||
return 100*x1 + 10*x2 + 1;
|
||||
}
|
||||
|
||||
int operator()( int x1, int x2 ) const &
|
||||
{
|
||||
return 100*x1 + 10*x2 + 2;
|
||||
}
|
||||
int operator()( int x1, int x2 ) &&
|
||||
{
|
||||
return 100*x1 + 10*x2 + 3;
|
||||
}
|
||||
int operator()( int x1, int x2 ) const &&
|
||||
{
|
||||
return 100*x1 + 10*x2 + 4;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1() )(), -1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1() )( 1 ), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1() )( 1, 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1() )( 1, 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1 )(), 1 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1 )( 2 ), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1 )( 2, 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1, 2 )(), 12 );
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1, 2 )( 3 ), 123 );
|
||||
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F1(), 1, 2, 3 )(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_EQ( boost::compat::bind_front( F2(), 9 )( 8 ), 983 );
|
||||
}
|
||||
|
||||
{
|
||||
auto fn = boost::compat::bind_front( F2(), 9 );
|
||||
BOOST_TEST_EQ( fn( 8 ), 981 );
|
||||
}
|
||||
|
||||
{
|
||||
auto const fn = boost::compat::bind_front( F2(), 9 );
|
||||
BOOST_TEST_EQ( fn( 8 ), 982 );
|
||||
}
|
||||
|
||||
{
|
||||
auto fn = boost::compat::bind_front( F2(), 9 );
|
||||
BOOST_TEST_EQ( std::move( fn )( 8 ), 983 );
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40900)
|
||||
|
||||
{
|
||||
auto const fn = boost::compat::bind_front( F2(), 9 );
|
||||
BOOST_TEST_EQ( std::move( fn )( 8 ), 984 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
55
test/integer_sequence_test.cpp
Normal file
55
test/integer_sequence_test.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright 2015 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/compat/integer_sequence.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::compat::integer_sequence;
|
||||
using boost::compat::make_integer_sequence;
|
||||
using boost::compat::index_sequence;
|
||||
using boost::compat::make_index_sequence;
|
||||
using boost::compat::index_sequence_for;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<int, 0>, integer_sequence<int>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<int, 1>, integer_sequence<int, 0>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<int, 2>, integer_sequence<int, 0, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<int, 3>, integer_sequence<int, 0, 1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<int, 4>, integer_sequence<int, 0, 1, 2, 3>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<char, 0>, integer_sequence<char>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<char, 1>, integer_sequence<char, 0>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<char, 2>, integer_sequence<char, 0, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<char, 3>, integer_sequence<char, 0, 1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<char, 4>, integer_sequence<char, 0, 1, 2, 3>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<std::size_t, 0>, integer_sequence<std::size_t>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<std::size_t, 1>, integer_sequence<std::size_t, 0>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<std::size_t, 2>, integer_sequence<std::size_t, 0, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<std::size_t, 3>, integer_sequence<std::size_t, 0, 1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(make_integer_sequence<std::size_t, 4>, integer_sequence<std::size_t, 0, 1, 2, 3>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<0>, integer_sequence<std::size_t>);
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<1>, integer_sequence<std::size_t, 0>);
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<2>, integer_sequence<std::size_t, 0, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<3>, integer_sequence<std::size_t, 0, 1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<4>, integer_sequence<std::size_t, 0, 1, 2, 3>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<0>, index_sequence<>);
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<1>, index_sequence<0>);
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<2>, index_sequence<0, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<3>, index_sequence<0, 1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(make_index_sequence<4>, index_sequence<0, 1, 2, 3>);
|
||||
|
||||
BOOST_TEST_TRAIT_SAME(index_sequence_for<>, index_sequence<>);
|
||||
BOOST_TEST_TRAIT_SAME(index_sequence_for<void>, index_sequence<0>);
|
||||
BOOST_TEST_TRAIT_SAME(index_sequence_for<void, void>, index_sequence<0, 1>);
|
||||
BOOST_TEST_TRAIT_SAME(index_sequence_for<void, void, void>, index_sequence<0, 1, 2>);
|
||||
BOOST_TEST_TRAIT_SAME(index_sequence_for<void, void, void, void>, index_sequence<0, 1, 2, 3>);
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -3,6 +3,9 @@
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/compat/latch.hpp>
|
||||
#include <boost/compat/shared_lock.hpp>
|
||||
#include <boost/compat/invoke.hpp>
|
||||
#include <boost/compat/bind_front.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user