diff --git a/include/rapidcheck/Gen.hpp b/include/rapidcheck/Gen.hpp index 7d8f124e..04eaaa44 100644 --- a/include/rapidcheck/Gen.hpp +++ b/include/rapidcheck/Gen.hpp @@ -12,7 +12,7 @@ namespace gen { // Forward declare this so we don't need to include Transform.h template -Gen::type>> map(Gen gen, +Gen::type>> map(Gen gen, Mapper &&mapper); } // namespace gen diff --git a/include/rapidcheck/Seq.h b/include/rapidcheck/Seq.h index aea770b9..af98784b 100644 --- a/include/rapidcheck/Seq.h +++ b/include/rapidcheck/Seq.h @@ -34,7 +34,7 @@ class Seq { /// Creates a new `Seq` using the implementation class specificed by the /// type parameter constructed by forwarding the given arguments. template - friend Seq::type::ValueType> + friend Seq::type::ValueType> makeSeq(Args &&... args); public: diff --git a/include/rapidcheck/Seq.hpp b/include/rapidcheck/Seq.hpp index d8cfe1dc..4295b8c6 100644 --- a/include/rapidcheck/Seq.hpp +++ b/include/rapidcheck/Seq.hpp @@ -59,8 +59,8 @@ Seq &Seq::operator=(const Seq &rhs) { } template -Seq::type::ValueType> makeSeq(Args &&... args) { - using SeqT = Seq::type::ValueType>; +Seq::type::ValueType> makeSeq(Args &&... args) { + using SeqT = Seq::type::ValueType>; using ImplT = typename SeqT::template SeqImpl; SeqT seq; diff --git a/include/rapidcheck/detail/ApplyTuple.h b/include/rapidcheck/detail/ApplyTuple.h index a664c18f..6d712838 100644 --- a/include/rapidcheck/detail/ApplyTuple.h +++ b/include/rapidcheck/detail/ApplyTuple.h @@ -13,7 +13,7 @@ struct ApplyTupleImpl; template struct ApplyTupleImpl, Callable, IndexSequence> { - using ReturnType = typename std::result_of::type; + using ReturnType = typename std::invoke_result::type; static ReturnType apply(std::tuple &&tuple, Callable &&callable) { return callable(std::move(std::get(tuple))...); @@ -24,7 +24,7 @@ template struct ApplyTupleImpl &, Callable, IndexSequence> { - using ReturnType = typename std::result_of::type; + using ReturnType = typename std::invoke_result::type; static ReturnType apply(std::tuple &tuple, Callable &&callable) { return callable(std::get(tuple)...); @@ -35,7 +35,7 @@ template struct ApplyTupleImpl &, Callable, IndexSequence> { - using ReturnType = typename std::result_of::type; + using ReturnType = typename std::invoke_result::type; static ReturnType apply(const std::tuple &tuple, Callable &&callable) { return callable(std::get(tuple)...); diff --git a/include/rapidcheck/gen/Container.hpp b/include/rapidcheck/gen/Container.hpp index 8e3d5c20..483e1a1e 100644 --- a/include/rapidcheck/gen/Container.hpp +++ b/include/rapidcheck/gen/Container.hpp @@ -244,7 +244,7 @@ class UniqueContainerStrategy { int size, std::size_t count, const Gen &gen) const { - using Key = Decay::type>; + using Key = Decay::type>; std::set values; return detail::generateShrinkables(random, size, @@ -259,7 +259,7 @@ class UniqueContainerStrategy { template Seq> shrinkElements(const Shrinkables &shrinkables) const { - using Key = Decay::type>; + using Key = Decay::type>; const auto keys = std::make_shared>(); for (const auto &shrinkable : shrinkables) { keys->insert(m_f(shrinkable.value())); diff --git a/include/rapidcheck/gen/Create.h b/include/rapidcheck/gen/Create.h index 0daf14a6..f5072809 100644 --- a/include/rapidcheck/gen/Create.h +++ b/include/rapidcheck/gen/Create.h @@ -13,7 +13,7 @@ Gen> just(T &&value); /// called lazily on actual generation. This is useful when implementing /// recursive generators where a generator must reference itself. template -Gen::type::ValueType> +Gen::type::ValueType> lazy(Callable &&callable); } // namespace gen diff --git a/include/rapidcheck/gen/Create.hpp b/include/rapidcheck/gen/Create.hpp index 09709c57..86ed598f 100644 --- a/include/rapidcheck/gen/Create.hpp +++ b/include/rapidcheck/gen/Create.hpp @@ -12,7 +12,7 @@ Gen> just(T &&value) { } template -Gen::type::ValueType> +Gen::type::ValueType> lazy(Callable &&callable) { return [=](const Random &random, int size) { return callable()(random, size); }; diff --git a/include/rapidcheck/gen/Transform.h b/include/rapidcheck/gen/Transform.h index b1243814..62978a84 100644 --- a/include/rapidcheck/gen/Transform.h +++ b/include/rapidcheck/gen/Transform.h @@ -8,19 +8,19 @@ namespace gen { /// Returns a generator based on the given generator but mapped with the given /// mapping function. template -Gen::type>> map(Gen gen, +Gen::type>> map(Gen gen, Mapper &&mapper); /// Convenience function which calls `map(Gen, Mapper)` with /// `gen::arbitrary` template -Gen::type>> map(Mapper &&mapper); +Gen::type>> map(Mapper &&mapper); /// Monadic bind. Takes a `Gen` and a function from a `T` to a `Gen` and /// returns a `Gen`. When shrinking, the value generated by the first /// generator will be shrunk first, then the second. template -Gen::type::ValueType> +Gen::type::ValueType> mapcat(Gen gen, Mapper &&mapper); /// Flattens a generator of generators of `T` into a generator of `T`. This is @@ -31,7 +31,7 @@ Gen join(Gen> gen); /// Calls the given callable with values generated by the given generators. Has /// tuple semantics when shrinking. template -Gen::type> +Gen::type> apply(Callable &&callable, Gen... gens); /// Returns a generator that casts the generated values to `T` using @@ -52,7 +52,7 @@ Gen scale(double scale, Gen gen); /// Creates a generator by taking a callable which gets passed the current size /// and is expected to return a generator. template -Gen::type::ValueType> +Gen::type::ValueType> withSize(Callable &&callable); /// Use this to disable shrinking for a given generator. When a failing case is diff --git a/include/rapidcheck/gen/Transform.hpp b/include/rapidcheck/gen/Transform.hpp index 70d5f1bb..758865fa 100644 --- a/include/rapidcheck/gen/Transform.hpp +++ b/include/rapidcheck/gen/Transform.hpp @@ -13,7 +13,7 @@ namespace detail { template class MapGen { public: - using U = Decay::type>; + using U = Decay::type>; template MapGen(Gen gen, MapperArg &&mapper) @@ -32,7 +32,7 @@ class MapGen { template class MapcatGen { public: - using U = typename std::result_of::type::ValueType; + using U = typename std::invoke_result::type::ValueType; template explicit MapcatGen(Gen gen, MapperArg &&mapper) @@ -73,19 +73,19 @@ class JoinGen { } // namespace detail template -Gen::type>> map(Gen gen, +Gen::type>> map(Gen gen, Mapper &&mapper) { return detail::MapGen>(std::move(gen), std::forward(mapper)); } template -Gen::type>> map(Mapper &&mapper) { +Gen::type>> map(Mapper &&mapper) { return gen::map(gen::arbitrary(), std::forward(mapper)); } template -Gen::type::ValueType> +Gen::type::ValueType> mapcat(Gen gen, Mapper &&mapper) { return detail::MapcatGen>(std::move(gen), std::forward(mapper)); @@ -97,7 +97,7 @@ Gen join(Gen> gen) { } template -Gen::type> apply(Callable &&callable, +Gen::type> apply(Callable &&callable, Gen... gens) { return gen::map(gen::tuple(std::move(gens)...), [=](std::tuple &&tuple) { @@ -124,7 +124,7 @@ Gen scale(double scale, Gen gen) { } template -Gen::type::ValueType> +Gen::type::ValueType> withSize(Callable &&callable) { return [=](const Random &random, int size) { return callable(size)(random, size); diff --git a/include/rapidcheck/seq/Transform.h b/include/rapidcheck/seq/Transform.h index 30e61034..8b213421 100644 --- a/include/rapidcheck/seq/Transform.h +++ b/include/rapidcheck/seq/Transform.h @@ -23,7 +23,7 @@ Seq takeWhile(Seq seq, Predicate &&pred); /// Maps the elements of the given `Seq` using the given callable. template -Seq::type>> map(Seq seq, +Seq::type>> map(Seq seq, Mapper &&mapper); /// Takes elements from the given `Seq`s and passes them as arguments to the @@ -33,7 +33,7 @@ Seq::type>> map(Seq seq, /// Fun fact: Also works with no sequences and in that case returns an infinite /// sequence of the return values of calling the given callable. template -Seq::type>> +Seq::type>> zipWith(Zipper &&zipper, Seq... seqs); /// Skips elements not matching the given predicate from the given stream. @@ -51,14 +51,14 @@ Seq concat(Seq seq, Seq... seqs); /// Maps each tuple elements of the given to `Seq`s to further `Seq`s and /// concatenates them into one `Seq`. Sometimes called a "flat map". template -Seq::type::ValueType> +Seq::type::ValueType> mapcat(Seq seq, Mapper &&mapper); /// Like `map` but expects the mapping functor to return a `Maybe`. If `Nothing` /// is returned, the element is skipped. Otherwise, the `Maybe` is unwrapped and /// included in the resulting `Seq`. template -Seq::type::ValueType> +Seq::type::ValueType> mapMaybe(Seq seq, Mapper &&mapper); /// Creates a `Seq` which infinitely repeats the given `Seq`. diff --git a/include/rapidcheck/seq/Transform.hpp b/include/rapidcheck/seq/Transform.hpp index df1253ac..446a33be 100644 --- a/include/rapidcheck/seq/Transform.hpp +++ b/include/rapidcheck/seq/Transform.hpp @@ -117,7 +117,7 @@ class TakeWhileSeq { template class MapSeq { public: - using U = Decay::type>; + using U = Decay::type>; template MapSeq(Seq seq, MapperArg &&mapper) @@ -142,7 +142,7 @@ class MapSeq { template class ZipWithSeq { public: - using U = Decay::type>; + using U = Decay::type>; template ZipWithSeq(ZipperArg &&zipper, Seq... seqs) @@ -263,7 +263,7 @@ class ConcatSeq { template class MapcatSeq { public: - using U = typename std::result_of::type::ValueType; + using U = typename std::invoke_result::type::ValueType; template MapcatSeq(Seq seq, MapperArg &&mapper) @@ -325,14 +325,14 @@ Seq takeWhile(Seq seq, Predicate &&pred) { } template -Seq::type>> map(Seq seq, +Seq::type>> map(Seq seq, Mapper &&mapper) { return makeSeq, T>>( std::move(seq), std::forward(mapper)); } template -Seq::type>> +Seq::type>> zipWith(Zipper &&zipper, Seq... seqs) { return makeSeq, Ts...>>( std::forward(zipper), std::move(seqs)...); @@ -356,16 +356,16 @@ Seq concat(Seq seq, Seq... seqs) { } template -Seq::type::ValueType> +Seq::type::ValueType> mapcat(Seq seq, Mapper &&mapper) { return makeSeq, T>>( std::move(seq), std::forward(mapper)); } template -Seq::type::ValueType> +Seq::type::ValueType> mapMaybe(Seq seq, Mapper &&mapper) { - using U = typename std::result_of::type::ValueType; + using U = typename std::invoke_result::type::ValueType; return seq::map( seq::filter(seq::map(std::move(seq), std::forward(mapper)), [](const Maybe &x) { return !!x; }), diff --git a/include/rapidcheck/shrink/Shrink.hpp b/include/rapidcheck/shrink/Shrink.hpp index 95b7fdd0..9e87721c 100644 --- a/include/rapidcheck/shrink/Shrink.hpp +++ b/include/rapidcheck/shrink/Shrink.hpp @@ -75,8 +75,8 @@ class RemoveChunksSeq { template class EachElementSeq { public: - using T = typename std::result_of::type::ValueType; + using T = typename std::invoke_result::type::ValueType; template explicit EachElementSeq(ContainerArg &&elements, ShrinkArg &&shrink) diff --git a/include/rapidcheck/shrinkable/Create.h b/include/rapidcheck/shrinkable/Create.h index 0341a1b2..f1d9e525 100644 --- a/include/rapidcheck/shrinkable/Create.h +++ b/include/rapidcheck/shrinkable/Create.h @@ -8,13 +8,13 @@ namespace shrinkable { /// Creates a `Shrinkable` from a callable which returns the value and a /// callable which returns the shrinks. template -Shrinkable::type> lambda(Value &&value, +Shrinkable::type> lambda(Value &&value, Shrink &&shrinks); /// Creates a `Shrinkable` with no shrinks from a callable which returns the /// value. template -Shrinkable::type> lambda(Value &&value); +Shrinkable::type> lambda(Value &&value); /// Creates a `Shrinkable` from an immediate value and an immediate sequence of /// shrinks. @@ -31,7 +31,7 @@ Shrinkable> just(T &&value); /// Creates a `Shrinkable` from a callable which returns the value and a /// callable that returns a `Seq>` when called with the value. template -Shrinkable::type> shrink(Value &&value, +Shrinkable::type> shrink(Value &&value, Shrink &&shrinkf); /// Creates a `Shrinkable` from an immediate value and a shrinking callable that diff --git a/include/rapidcheck/shrinkable/Create.hpp b/include/rapidcheck/shrinkable/Create.hpp index db8691c3..61556697 100644 --- a/include/rapidcheck/shrinkable/Create.hpp +++ b/include/rapidcheck/shrinkable/Create.hpp @@ -10,7 +10,7 @@ namespace detail { template class LambdaShrinkable { public: - using T = Decay::type>; + using T = Decay::type>; template LambdaShrinkable(ValueArg &&value, ShrinkArg &&shrinks) @@ -29,7 +29,7 @@ template class JustShrinkShrinkable // Yeah I know, weird name { public: - using T = Decay::type>; + using T = Decay::type>; template JustShrinkShrinkable(ValueArg &&value, ShrinkArg &&shrinks) @@ -49,7 +49,7 @@ class JustShrinkShrinkable // Yeah I know, weird name // TODO test _all_ of these? template -Shrinkable::type> lambda(Value &&value, +Shrinkable::type> lambda(Value &&value, Shrink &&shrinks) { using Impl = detail::LambdaShrinkable, Decay>; return makeShrinkable(std::forward(value), @@ -57,8 +57,8 @@ Shrinkable::type> lambda(Value &&value, } template -Shrinkable::type> lambda(Value &&value) { - using T = typename std::result_of::type; +Shrinkable::type> lambda(Value &&value) { + using T = typename std::invoke_result::type; return shrinkable::lambda(std::forward(value), fn::constant(Seq>())); } @@ -75,7 +75,7 @@ Shrinkable> just(T &&value) { } template -Shrinkable::type> shrink(Value &&value, +Shrinkable::type> shrink(Value &&value, Shrink &&shrinkf) { using Impl = detail::JustShrinkShrinkable, Decay>; return makeShrinkable(std::forward(value), diff --git a/include/rapidcheck/shrinkable/Transform.h b/include/rapidcheck/shrinkable/Transform.h index 058a671a..7df80508 100644 --- a/include/rapidcheck/shrinkable/Transform.h +++ b/include/rapidcheck/shrinkable/Transform.h @@ -7,7 +7,7 @@ namespace shrinkable { /// Maps the given shrinkable recursively using the given mapping callable. template -Shrinkable::type>> +Shrinkable::type>> map(Shrinkable shrinkable, Mapper &&mapper); /// Returns a shrinkable equal to the given shrinkable but with the shrinks @@ -26,7 +26,7 @@ Maybe> filter(Shrinkable shrinkable, Predicate &&pred); /// `Shrinkable` and returns a `Shrinkable` that shrinks by first /// shrinking the first value and then shrinking the second value. template -Shrinkable::type::ValueType> +Shrinkable::type::ValueType> mapcat(Shrinkable shrinkable, Mapper &&mapper); /// Given two `Shrinkables`, returns a `Shrinkable` pair that first shrinks the diff --git a/include/rapidcheck/shrinkable/Transform.hpp b/include/rapidcheck/shrinkable/Transform.hpp index ab15bdd0..24bbd5f3 100644 --- a/include/rapidcheck/shrinkable/Transform.hpp +++ b/include/rapidcheck/shrinkable/Transform.hpp @@ -10,7 +10,7 @@ namespace detail { template class MapShrinkable { public: - using U = Decay::type>; + using U = Decay::type>; template MapShrinkable(Shrinkable shrinkable, MapperArg &&mapper) @@ -54,7 +54,7 @@ class MapShrinksShrinkable { template class MapcatShrinkable { public: - using U = typename std::result_of::type::ValueType; + using U = typename std::invoke_result::type::ValueType; template MapcatShrinkable(Shrinkable shrinkable, MapperArg &&mapper) @@ -81,7 +81,7 @@ class MapcatShrinkable { } // namespace detail template -Shrinkable::type>> +Shrinkable::type>> map(Shrinkable shrinkable, Mapper &&mapper) { using Impl = detail::MapShrinkable>; return makeShrinkable(std::move(shrinkable), @@ -113,7 +113,7 @@ Maybe> filter(Shrinkable shrinkable, Predicate &&pred) { } template -Shrinkable::type::ValueType> +Shrinkable::type::ValueType> mapcat(Shrinkable shrinkable, Mapper &&mapper) { using Impl = detail::MapcatShrinkable>; return makeShrinkable(std::move(shrinkable), diff --git a/include/rapidcheck/state/gen/Commands.hpp b/include/rapidcheck/state/gen/Commands.hpp index 86df0f78..7d202452 100644 --- a/include/rapidcheck/state/gen/Commands.hpp +++ b/include/rapidcheck/state/gen/Commands.hpp @@ -14,8 +14,8 @@ namespace detail { template class CommandsGen { public: - using Model = Decay::type>; - using CommandGen = typename std::result_of::type; + using Model = Decay::type>; + using CommandGen = typename std::invoke_result::type; using Cmd = typename CommandGen::ValueType::element_type::CommandType; using CmdSP = std::shared_ptr; using Sut = typename Cmd::Sut; diff --git a/test/ShrinkableTests.cpp b/test/ShrinkableTests.cpp index f78bc9b4..e6ca1593 100644 --- a/test/ShrinkableTests.cpp +++ b/test/ShrinkableTests.cpp @@ -21,11 +21,11 @@ class MockShrinkableImpl { : m_value(value) , m_shrinks(shrinks) {} - typename std::result_of::type value() const { + typename std::invoke_result::type value() const { return m_value(); } - typename std::result_of::type shrinks() const { + typename std::invoke_result::type shrinks() const { return m_shrinks(); } @@ -35,7 +35,7 @@ class MockShrinkableImpl { }; template -Shrinkable::type>> +Shrinkable::type>> makeMockShrinkable(ValueCallable value, ShrinksCallable shrinks) { return makeShrinkable>( value, shrinks);