forked from ericniebler/range-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
view and action examples; workaround for gcc-7/8 ICE, fixes ericniebl…
…er#1105 (ericniebler#1274) view and action examples; workaround for gcc-7/8 ICE, fixes ericniebler#1105
- Loading branch information
1 parent
94f9516
commit e3f7291
Showing
14 changed files
with
295 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule gh-pages
updated
22 files
+151 −0 | concepts_2concepts_8hpp.html | |
+15 −0 | concepts_2concepts_8hpp.js | |
+11 −13 | index.html | |
+7 −0 | interface_8hpp.html | |
+1 −0 | interface_8hpp.js | |
+10 −4 | md___users_eniebler__code_range-v3_doc_examples.html | |
+21 −15 | navtreedata.js | |
+136 −136 | navtreeindex1.js | |
+22 −22 | navtreeindex10.js | |
+21 −21 | navtreeindex11.js | |
+22 −22 | navtreeindex12.js | |
+21 −21 | navtreeindex13.js | |
+20 −0 | navtreeindex14.js | |
+16 −16 | navtreeindex2.js | |
+16 −16 | navtreeindex3.js | |
+22 −22 | navtreeindex4.js | |
+21 −21 | navtreeindex5.js | |
+21 −21 | navtreeindex6.js | |
+22 −22 | navtreeindex7.js | |
+21 −21 | navtreeindex8.js | |
+21 −21 | navtreeindex9.js | |
+2 −1 | structranges_1_1view__interface.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Range v3 library | ||
// | ||
// Copyright Eric Niebler 2019 | ||
// | ||
// Use, modification and distribution is subject to the | ||
// Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
// Project home: https://github.com/ericniebler/range-v3 | ||
// | ||
|
||
///[accumulate_ints] | ||
// Sums the first ten squares and prints them, using views::ints to generate | ||
// and infinite range of integers, views::transform to square them, views::take | ||
// to drop all but the first 10, and accumulate to sum them. | ||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <range/v3/numeric/accumulate.hpp> | ||
#include <range/v3/view/iota.hpp> | ||
#include <range/v3/view/take.hpp> | ||
#include <range/v3/view/transform.hpp> | ||
using std::cout; | ||
|
||
int main() | ||
{ | ||
using namespace ranges; | ||
int sum = accumulate(views::ints(1, unreachable) | views::transform([](int i) { | ||
return i * i; | ||
}) | views::take(10), | ||
0); | ||
// prints: 385 | ||
cout << sum << '\n'; | ||
} | ||
///[accumulate_ints] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Range v3 library | ||
// | ||
// Copyright Eric Niebler 2019 | ||
// | ||
// Use, modification and distribution is subject to the | ||
// Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
// Project home: https://github.com/ericniebler/range-v3 | ||
// | ||
|
||
///[comprehension_conversion] | ||
// Use a range comprehension (views::for_each) to construct a custom range, and | ||
// then convert it to a std::vector. | ||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <range/v3/range/conversion.hpp> | ||
#include <range/v3/view/for_each.hpp> | ||
#include <range/v3/view/iota.hpp> | ||
#include <range/v3/view/repeat_n.hpp> | ||
using std::cout; | ||
|
||
int main() | ||
{ | ||
using namespace ranges; | ||
auto vi = views::for_each(views::ints(1, 6), | ||
[](int i) { return yield_from(views::repeat_n(i, i)); }) | | ||
to<std::vector>(); | ||
// prints: [1,2,2,3,3,3,4,4,4,4,5,5,5,5,5] | ||
cout << views::all(vi) << '\n'; | ||
} | ||
///[comprehension_conversion] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
// Range v3 library | ||
// | ||
// Copyright Jeff Garland 2017 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Range v3 library | ||
// | ||
// Copyright Eric Niebler 2019 | ||
// | ||
// Use, modification and distribution is subject to the | ||
// Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
// Project home: https://github.com/ericniebler/range-v3 | ||
// | ||
|
||
///[filter_transform] | ||
// This example demonstrates filtering and transforming a range on the | ||
// fly with view adaptors. | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include <range/v3/view/filter.hpp> | ||
#include <range/v3/view/transform.hpp> | ||
using std::cout; | ||
|
||
int main() | ||
{ | ||
std::vector<int> const vi{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | ||
using namespace ranges; | ||
auto rng = vi | views::filter([](int i) { return i % 2 == 0; }) | | ||
views::transform([](int i) { return std::to_string(i); }); | ||
// prints: [2,4,6,8,10] | ||
cout << rng << '\n'; | ||
} | ||
///[filter_transform] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Range v3 library | ||
// | ||
// Copyright Eric Niebler 2019 | ||
// | ||
// Use, modification and distribution is subject to the | ||
// Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
// Project home: https://github.com/ericniebler/range-v3 | ||
// | ||
|
||
///[sort_unique] | ||
// Remove all non-unique elements from a container. | ||
|
||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <range/v3/action/sort.hpp> | ||
#include <range/v3/action/unique.hpp> | ||
#include <range/v3/view/all.hpp> | ||
using std::cout; | ||
|
||
int main() | ||
{ | ||
std::vector<int> vi{9, 4, 5, 2, 9, 1, 0, 2, 6, 7, 4, 5, 6, 5, 9, 2, 7, | ||
1, 4, 5, 3, 8, 5, 0, 2, 9, 3, 7, 5, 7, 5, 5, 6, 1, | ||
4, 3, 1, 8, 4, 0, 7, 8, 8, 2, 6, 5, 3, 4, 5}; | ||
using namespace ranges; | ||
vi |= actions::sort | actions::unique; | ||
// prints: [0,1,2,3,4,5,6,7,8,9] | ||
cout << views::all(vi) << '\n'; | ||
} | ||
///[sort_unique] |
Oops, something went wrong.