File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1759,6 +1759,12 @@ bool none_of(R &&Range, UnaryPredicate P) {
17591759 return std::none_of (adl_begin (Range), adl_end (Range), P);
17601760}
17611761
1762+ // / Provide wrappers to std::fill which take ranges instead of having to pass
1763+ // / begin/end explicitly.
1764+ template <typename R, typename T> void fill (R &&Range, T &&Value) {
1765+ std::fill (adl_begin (Range), adl_end (Range), std::forward<T>(Value));
1766+ }
1767+
17621768// / Provide wrappers to std::find which take ranges instead of having to pass
17631769// / begin/end explicitly.
17641770template <typename R, typename T> auto find (R &&Range, const T &Val) {
Original file line number Diff line number Diff line change @@ -1591,6 +1591,18 @@ TEST(STLExtrasTest, Includes) {
15911591 }
15921592}
15931593
1594+ TEST (STLExtrasTest, Fill) {
1595+ std::vector<int > V1 = {1 , 2 , 3 };
1596+ std::vector<int > V2;
1597+ int Val = 4 ;
1598+ auto IsSameAsVal = [&](int V) { return V == Val; };
1599+ fill (V1, Val);
1600+ EXPECT_TRUE (llvm::all_of (V1, IsSameAsVal));
1601+ V2.resize (5 );
1602+ fill (V2, Val);
1603+ EXPECT_TRUE (llvm::all_of (V2, IsSameAsVal));
1604+ }
1605+
15941606struct Foo ;
15951607struct Bar {};
15961608
You can’t perform that action at this time.
0 commit comments