Index: test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp +++ test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp @@ -16,8 +16,11 @@ // #include -#include +#include #include +#include +#include +#include #include "test_iterators.h" Index: test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp +++ test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp @@ -17,8 +17,11 @@ // T init, BinaryOperation binary_op); // C++17 #include -#include +#include #include +#include +#include +#include #include "test_iterators.h" @@ -70,7 +73,7 @@ // Make sure that the calculations are done using the init typedef { std::vector v(10); - std::iota(v.begin(), v.end(), 1); + std::iota(v.begin(), v.end(), static_cast(1)); std::vector res; std::exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>()); Index: test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp +++ test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp @@ -16,8 +16,11 @@ // #include -#include +#include #include +#include +#include +#include #include "test_iterators.h" Index: test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp +++ test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp @@ -17,9 +17,12 @@ // BinaryOperation binary_op); // C++17 #include -#include +#include #include +#include #include +#include +#include #include "test_iterators.h" Index: test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp +++ test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp @@ -17,8 +17,11 @@ // BinaryOperation binary_op, T init); // C++17 #include -#include +#include #include +#include +#include +#include #include "test_iterators.h" @@ -95,7 +98,7 @@ // Make sure that the calculations are done using the init typedef { std::vector v(10); - std::iota(v.begin(), v.end(), 1); + std::iota(v.begin(), v.end(), static_cast(1)); std::vector res; std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), 1); Index: test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp +++ test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp @@ -19,26 +19,20 @@ #include -#include +#include #include +#include #include +#include +#include #include "test_iterators.h" -template -struct identity : std::unary_function -{ - constexpr const T& operator()(const T& x) const { return x;} -}; - -template <> -struct identity -{ - template - constexpr auto operator()(T&& x) const - _NOEXCEPT_(noexcept(_VSTD::forward(x))) - -> decltype (_VSTD::forward(x)) - { return _VSTD::forward(x); } +struct add_ten { + template + constexpr auto operator()(T x) const noexcept { + return static_cast(x + 10); + } }; template @@ -63,14 +57,14 @@ test() { int ia[] = { 1, 3, 5, 7, 9}; - const int pResI0[] = { 0, 1, 4, 9, 16}; // with identity + const int pResI0[] = { 0, 11, 24, 39, 56}; // with add_ten const int mResI0[] = { 0, 0, 0, 0, 0}; const int pResN0[] = { 0, -1, -4, -9, -16}; // with negate const int mResN0[] = { 0, 0, 0, 0, 0}; - const int pResI2[] = { 2, 3, 6, 11, 18}; // with identity - const int mResI2[] = { 2, 2, 6, 30, 210}; - const int pResN2[] = { 2, 1, -2, -7, -14}; // with negate - const int mResN2[] = { 2, -2, 6, -30, 210}; + const int pResI2[] = { 2, 13, 26, 41, 58}; // with add_ten + const int mResI2[] = { 2, 22, 286, 4290, 72930}; + const int pResN2[] = { 2, 1, -2, -7, -14}; // with negate + const int mResN2[] = { 2, -2, 6, -30, 210}; const unsigned sa = sizeof(ia) / sizeof(ia[0]); static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0])); // just to be sure static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0])); // just to be sure @@ -82,12 +76,12 @@ static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0])); // just to be sure for (unsigned int i = 0; i < sa; ++i ) { - test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 0, pResI0, pResI0 + i); - test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 0, mResI0, mResI0 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), add_ten{}, 0, pResI0, pResI0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_ten{}, 0, mResI0, mResI0 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 0, pResN0, pResN0 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i); - test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 2, pResI2, pResI2 + i); - test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 2, mResI2, mResI2 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), add_ten{}, 2, pResI2, pResI2 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_ten{}, 2, mResI2, mResI2 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 2, pResN2, pResN2 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i); } @@ -101,46 +95,46 @@ { std::vector v(10); std::fill(v.begin(), v.end(), 3); - std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 50, std::plus<>(), identity<>()); + std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 50, std::plus<>(), add_ten{}); for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == 50 + (int) i * 3); + assert(v[i] == 50 + (int) i * 13); } { std::vector v(10); std::iota(v.begin(), v.end(), 0); - std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 30, std::plus<>(), identity<>()); + std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 30, std::plus<>(), add_ten{}); for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == 30 + triangle(i-1)); + assert(v[i] == 30 + triangle(i - 1) + i * 10); } { std::vector v(10); std::iota(v.begin(), v.end(), 1); - std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 40, std::plus<>(), identity<>()); + std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 40, std::plus<>(), add_ten{}); for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == 40 + triangle(i)); + assert(v[i] == 40 + triangle(i) + i * 10); } { std::vector v, res; - std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 40, std::plus<>(), identity<>()); + std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 40, std::plus<>(), add_ten{}); assert(res.empty()); } // Make sure that the calculations are done using the init typedef { std::vector v(10); - std::iota(v.begin(), v.end(), 1); + std::iota(v.begin(), v.end(), static_cast(1)); std::vector res; - std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>(), identity<>()); + std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>(), add_ten{}); assert(res.size() == 10); int j = 1; assert(res[0] == 1); for (size_t i = 1; i < res.size(); ++i) { - j *= i; + j *= i + 10; assert(res[i] == j); } } Index: test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp +++ test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp @@ -20,26 +20,20 @@ #include -#include +#include #include +#include #include +#include +#include #include "test_iterators.h" -template -struct identity : std::unary_function -{ - constexpr const T& operator()(const T& x) const { return x;} -}; - -template <> -struct identity -{ - template - constexpr auto operator()(T&& x) const - _NOEXCEPT_(noexcept(_VSTD::forward(x))) - -> decltype (_VSTD::forward(x)) - { return _VSTD::forward(x); } +struct add_ten { + template + constexpr auto operator()(T x) const noexcept { + return static_cast(x + 10); + } }; template @@ -64,8 +58,8 @@ test() { int ia[] = { 1, 3, 5, 7, 9}; - const int pResI0[] = { 1, 4, 9, 16, 25}; // with identity - const int mResI0[] = { 1, 3, 15, 105, 945}; + const int pResI0[] = { 11, 24, 39, 56, 75}; // with add_ten + const int mResI0[] = { 11, 143, 2145, 36465, 692835}; const int pResN0[] = { -1, -4, -9, -16, -25}; // with negate const int mResN0[] = { -1, 3, -15, 105, -945}; const unsigned sa = sizeof(ia) / sizeof(ia[0]); @@ -75,8 +69,8 @@ static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0])); // just to be sure for (unsigned int i = 0; i < sa; ++i ) { - test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), pResI0, pResI0 + i); - test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), mResI0, mResI0 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), add_ten{}, pResI0, pResI0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_ten{}, mResI0, mResI0 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), pResN0, pResN0 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), mResN0, mResN0 + i); } @@ -90,32 +84,32 @@ { std::vector v(10); std::fill(v.begin(), v.end(), 3); - std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>()); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_ten{}); std::copy(v.begin(), v.end(), std::ostream_iterator(std::cout, " ")); std::cout << std::endl; for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == (int)(i+1) * 3); + assert(v[i] == (int)(i+1) * 13); } { std::vector v(10); std::iota(v.begin(), v.end(), 0); - std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>()); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_ten{}); for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == triangle(i)); + assert(v[i] == triangle(i) + (i + 1) * 10); } { std::vector v(10); std::iota(v.begin(), v.end(), 1); - std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>()); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_ten{}); for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == triangle(i + 1)); + assert(v[i] == triangle(i + 1) + (i + 1) * 10); } { std::vector v, res; - std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), identity<>()); + std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), add_ten{}); assert(res.empty()); } } Index: test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp +++ test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp @@ -20,25 +20,19 @@ #include -#include +#include #include +#include +#include +#include #include "test_iterators.h" -template -struct identity : std::unary_function -{ - constexpr const T& operator()(const T& x) const { return x;} -}; - -template <> -struct identity -{ - template - constexpr auto operator()(T&& x) const - _NOEXCEPT_(noexcept(_VSTD::forward(x))) - -> decltype (_VSTD::forward(x)) - { return _VSTD::forward(x); } +struct add_ten { + template + constexpr auto operator()(T x) const noexcept { + return static_cast(x + 10); + } }; template @@ -63,12 +57,12 @@ test() { int ia[] = { 1, 3, 5, 7, 9}; - const int pResI0[] = { 1, 4, 9, 16, 25}; // with identity + const int pResI0[] = { 11, 24, 39, 56, 75}; // with add_ten const int mResI0[] = { 0, 0, 0, 0, 0}; const int pResN0[] = { -1, -4, -9, -16, -25}; // with negate const int mResN0[] = { 0, 0, 0, 0, 0}; - const int pResI2[] = { 3, 6, 11, 18, 27}; // with identity - const int mResI2[] = { 2, 6, 30, 210, 1890}; + const int pResI2[] = { 13, 26, 41, 58, 77}; // with add_ten + const int mResI2[] = { 22, 286, 4290, 72930, 1385670}; const int pResN2[] = { 1, -2, -7, -14, -23}; // with negate const int mResN2[] = { -2, 6, -30, 210, -1890}; const unsigned sa = sizeof(ia) / sizeof(ia[0]); @@ -82,12 +76,12 @@ static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0])); // just to be sure for (unsigned int i = 0; i < sa; ++i ) { - test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 0, pResI0, pResI0 + i); - test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 0, mResI0, mResI0 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), add_ten{}, 0, pResI0, pResI0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_ten{}, 0, mResI0, mResI0 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 0, pResN0, pResN0 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i); - test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 2, pResI2, pResI2 + i); - test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 2, mResI2, mResI2 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), add_ten{}, 2, pResI2, pResI2 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_ten{}, 2, mResI2, mResI2 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 2, pResN2, pResN2 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i); } @@ -101,46 +95,46 @@ { std::vector v(10); std::fill(v.begin(), v.end(), 3); - std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 50); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_ten{}, 50); for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == 50 + (int) (i + 1) * 3); + assert(v[i] == 50 + (int) (i + 1) * 13); } { std::vector v(10); std::iota(v.begin(), v.end(), 0); - std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 30); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_ten{}, 30); for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == 30 + triangle(i)); + assert(v[i] == 30 + triangle(i) + (i + 1) * 10); } { std::vector v(10); std::iota(v.begin(), v.end(), 1); - std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 40); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), add_ten{}, 40); for (size_t i = 0; i < v.size(); ++i) - assert(v[i] == 40 + triangle(i + 1)); + assert(v[i] == 40 + triangle(i + 1) + (i + 1) * 10); } { std::vector v, res; - std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), identity<>(), 1); + std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), add_ten{}, 1); assert(res.empty()); } // Make sure that the calculations are done using the init typedef { std::vector v(10); - std::iota(v.begin(), v.end(), 1); + std::iota(v.begin(), v.end(), static_cast(1)); std::vector res; - std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), identity<>(), 1); + std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), add_ten{}, 1); assert(res.size() == 10); - int j = 1; - assert(res[0] == 1); + int j = 11; + assert(res[0] == 11); for (size_t i = 1; i < res.size(); ++i) { - j *= i + 1; + j *= i + 11; assert(res[i] == j); } }