This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix Xxx_scan tests using nonstandard things and MSVC++ warnings
ClosedPublic

Authored by BillyONeal on Jan 4 2018, 5:02 PM.

Details

Summary
  • These tests use function objects from functional, back_inserter from iterator, and equal from algorithm, so add those headers.
  • The use of iota targeting vector<unsigned char> with an int parameter triggers warnings on MSVC++ assigning an into a unsigned char&; so change the parameter to unsigned char with a static_cast.
  • Avoid naming unary_function in identity here as that is removed in '17. (This also fixes naming _VSTD, _NOEXCEPT_, and other libcxx-isms)

Diff Detail

Event Timeline

BillyONeal created this revision.Jan 4 2018, 5:02 PM
CaseyCarter added inline comments.
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
36

Pre-existing: the identity transformation is an extremely poor choice for these transform_foo tests since failure to apply the transformation exactly once to each element does not affect the result of the algorithm.

The use of iota targeting vector<unsigned char> with an int parameter triggers warnings on MSVC++ assigning an into a unsigned char&

I hate your compiler.

Other than that (and the bit about identity), this looks fine to me.

test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
36

I think I'd rather have this. It's constexpr and noexcept, unlike the lambda.

struct identity {
    template <typename T>
    constexpr auto operator()(T&& x) const
    noexcept(noexcept(std::forward<T>(x)))
    -> decltype      (std::forward<T>(x))
        { return      std::forward<T>(x); }
};
36

I agree about the choice of identity as a transform.

BillyONeal updated this revision to Diff 128836.Jan 5 2018, 6:14 PM
BillyONeal marked 3 inline comments as done.

Also change predicate from identity to add_ten.

I hate your compiler.

Seems like a valid warning to me :)

Changed predicate to one that adds 10 to each input.

CaseyCarter added inline comments.Jan 5 2018, 6:32 PM
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
33

Although it doesn't matter to these tests, this notably doesn't have return type SFINAE as @mclow.lists suggested in his comment. Marshall, do you care, and if so, why?

@EricWF / @mclow.lists Any chance you could take a look sometime soon?

BillyONeal accepted this revision.Apr 10 2018, 7:41 PM

It actually looks like I accidentally committed this back in January so I'm going to close this :)

This revision is now accepted and ready to land.Apr 10 2018, 7:41 PM
BillyONeal closed this revision.Apr 10 2018, 7:41 PM