forked from OSchip/llvm-project
In C++03, a bunch of the arithmetic/logical/comparison functors (such as add/equal_to/logical_or) were defined as deriving from binary_funtion. That restriction was removed in C++11, but the tests still check for this. Change the test to look for the embedded types first_argument/second_argument/result_type. No change to the library, just more standards-compliant tests. Thanks to STL @ Microsoft for the suggestion.
llvm-svn: 225375
This commit is contained in:
parent
627df427eb
commit
66369c03a3
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::divides<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::result_type>::value), "" );
|
||||
assert(f(36, 4) == 9);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::divides<> F2;
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::minus<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::result_type>::value), "" );
|
||||
assert(f(3, 2) == 1);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::minus<> F2;
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::modulus<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::result_type>::value), "" );
|
||||
assert(f(36, 8) == 4);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::modulus<> F2;
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::multiplies<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::result_type>::value), "" );
|
||||
assert(f(3, 2) == 6);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::multiplies<> F2;
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::plus<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::result_type>::value), "" );
|
||||
assert(f(3, 2) == 5);
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
typedef std::plus<> F2;
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::bit_and<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::result_type>::value), "" );
|
||||
assert(f(0xEA95, 0xEA95) == 0xEA95);
|
||||
assert(f(0xEA95, 0x58D3) == 0x4891);
|
||||
assert(f(0x58D3, 0xEA95) == 0x4891);
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::bit_or<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::result_type>::value), "" );
|
||||
assert(f(0xEA95, 0xEA95) == 0xEA95);
|
||||
assert(f(0xEA95, 0x58D3) == 0xFAD7);
|
||||
assert(f(0x58D3, 0xEA95) == 0xFAD7);
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::bit_xor<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::result_type>::value), "" );
|
||||
assert(f(0xEA95, 0xEA95) == 0);
|
||||
assert(f(0xEA95, 0x58D3) == 0xB246);
|
||||
assert(f(0x58D3, 0xEA95) == 0xB246);
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::equal_to<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<bool, F::result_type>::value), "" );
|
||||
assert(f(36, 36));
|
||||
assert(!f(36, 6));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::greater<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<bool, F::result_type>::value), "" );
|
||||
assert(!f(36, 36));
|
||||
assert(f(36, 6));
|
||||
assert(!f(6, 36));
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::greater_equal<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<bool, F::result_type>::value), "" );
|
||||
assert(f(36, 36));
|
||||
assert(f(36, 6));
|
||||
assert(!f(6, 36));
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::less_equal<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<bool, F::result_type>::value), "" );
|
||||
assert(f(36, 36));
|
||||
assert(!f(36, 6));
|
||||
assert(f(6, 36));
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::not_equal_to<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<bool, F::result_type>::value), "" );
|
||||
assert(!f(36, 36));
|
||||
assert(f(36, 6));
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::logical_and<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<bool, F::result_type>::value), "" );
|
||||
assert(f(36, 36));
|
||||
assert(!f(36, 0));
|
||||
assert(!f(0, 36));
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::logical_or<int> F;
|
||||
const F f = F();
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<bool, F::result_type>::value), "" );
|
||||
assert(f(36, 36));
|
||||
assert(f(36, 0));
|
||||
assert(f(0, 36));
|
||||
|
|
|
@ -19,7 +19,9 @@ int main()
|
|||
{
|
||||
typedef std::binary_negate<std::logical_and<int> > F;
|
||||
const F f = F(std::logical_and<int>());
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
|
||||
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
|
||||
static_assert((std::is_same<int, F::second_argument_type>::value), "" );
|
||||
static_assert((std::is_same<bool, F::result_type>::value), "" );
|
||||
assert(!f(36, 36));
|
||||
assert( f(36, 0));
|
||||
assert( f(0, 36));
|
||||
|
|
Loading…
Reference in New Issue