File tree 2 files changed +24
-4
lines changed
2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -311,14 +311,14 @@ template <typename iteratort>
311
311
struct ranget final
312
312
{
313
313
public:
314
- using value_typet = typename iteratort::value_type;
314
+ using value_type = typename iteratort::value_type;
315
315
316
316
ranget (iteratort begin, iteratort end) : begin_value(begin), end_value(end)
317
317
{
318
318
}
319
319
320
320
ranget<filter_iteratort<iteratort>>
321
- filter (std::function<bool (const value_typet &)> f)
321
+ filter (std::function<bool (const value_type &)> f)
322
322
{
323
323
auto shared_f = std::make_shared<decltype (f)>(std::move (f));
324
324
filter_iteratort<iteratort> filter_begin (shared_f, begin (), end ());
@@ -335,9 +335,9 @@ struct ranget final
335
335
template <typename functiont>
336
336
auto map (functiont &&f) -> ranget<map_iteratort<
337
337
iteratort,
338
- typename std::result_of<functiont(value_typet )>::type>>
338
+ typename std::result_of<functiont(value_type )>::type>>
339
339
{
340
- using outputt = typename std::result_of<functiont (value_typet )>::type;
340
+ using outputt = typename std::result_of<functiont (value_type )>::type;
341
341
auto shared_f = std::make_shared<
342
342
std::function<outputt (const typename iteratort::value_type &)>>(
343
343
std::forward<functiont>(f));
Original file line number Diff line number Diff line change 11
11
#include < testing-utils/catch.hpp>
12
12
#include < util/range.h>
13
13
14
+ // / Trivial example template function requiring a container to have a
15
+ // / `value_type`.
16
+ template <typename containert>
17
+ typename containert::value_type front (containert container)
18
+ {
19
+ return *container.begin ();
20
+ }
21
+
14
22
SCENARIO (" range tests" , " [core][util][range]" )
15
23
{
16
24
GIVEN (" A vector with three strings" )
@@ -75,6 +83,18 @@ SCENARIO("range tests", "[core][util][range]")
75
83
const std::vector<int > expected_odds{1 , 3 };
76
84
REQUIRE (odds == expected_odds);
77
85
}
86
+ THEN (
87
+ " The unit testing template function requiring `value_type` works with "
88
+ " `std::vector`." )
89
+ {
90
+ REQUIRE (front (input) == 1 );
91
+ }
92
+ THEN (
93
+ " A range can be used with a template function expecting a container "
94
+ " which has a `value_type`." )
95
+ {
96
+ REQUIRE (front (make_range (input)) == 1 );
97
+ }
78
98
}
79
99
GIVEN (" Two const vectors of ints" )
80
100
{
You can’t perform that action at this time.
0 commit comments