├── .gitmodules ├── perf └── CMakeLists.txt ├── doc ├── std │ ├── show.cmd │ ├── header.html │ └── pandoc-template.html └── CMakeLists.txt ├── .gitattributes ├── test ├── algorithm │ ├── is_heap1.cpp │ ├── is_heap2.cpp │ ├── is_heap3.cpp │ ├── is_heap4.cpp │ ├── set_union1.cpp │ ├── set_union2.cpp │ ├── set_union3.cpp │ ├── set_union4.cpp │ ├── set_union5.cpp │ ├── set_union6.cpp │ ├── is_heap_until1.cpp │ ├── is_heap_until2.cpp │ ├── is_heap_until3.cpp │ ├── is_heap_until4.cpp │ ├── set_difference1.cpp │ ├── set_difference2.cpp │ ├── set_difference3.cpp │ ├── set_difference4.cpp │ ├── set_difference5.cpp │ ├── set_difference6.cpp │ ├── set_intersection1.cpp │ ├── set_intersection2.cpp │ ├── set_intersection3.cpp │ ├── set_intersection4.cpp │ ├── set_intersection5.cpp │ ├── set_intersection6.cpp │ ├── set_symmetric_difference1.cpp │ ├── set_symmetric_difference2.cpp │ ├── set_symmetric_difference3.cpp │ ├── set_symmetric_difference4.cpp │ ├── set_symmetric_difference5.cpp │ ├── set_symmetric_difference6.cpp │ ├── adjacent_find.cpp │ ├── for_each.cpp │ ├── copy_backward.cpp │ ├── binary_search.cpp │ ├── all_of.cpp │ ├── any_of.cpp │ ├── find.cpp │ ├── none_of.cpp │ ├── generate_n.cpp │ ├── count.cpp │ ├── copy.cpp │ ├── shuffle.cpp │ ├── lower_bound.cpp │ └── find_if.cpp ├── multiple1.cpp ├── numeric │ ├── CMakeLists.txt │ └── iota.cpp ├── multiple2.cpp ├── istream_range.cpp ├── getlines.cpp ├── utility │ ├── CMakeLists.txt │ ├── iterator.cpp │ └── functional.cpp ├── view │ ├── repeat.cpp │ ├── indirect.cpp │ ├── unique.cpp │ ├── tokenize.cpp │ ├── delimit.cpp │ ├── all.cpp │ ├── keys_value.cpp │ ├── generate_n.cpp │ ├── generate.cpp │ ├── move.cpp │ ├── counted.cpp │ ├── partial_sum.cpp │ ├── any_view.cpp │ ├── drop_while.cpp │ ├── take_while.cpp │ ├── stride.cpp │ ├── adjacent_remove_if.cpp │ ├── bounded.cpp │ ├── drop.cpp │ └── take_exactly.cpp ├── action │ ├── remove_if.cpp │ ├── drop.cpp │ ├── transform.cpp │ ├── take.cpp │ ├── drop_while.cpp │ ├── cont_concepts.cpp │ ├── slice.cpp │ ├── take_while.cpp │ ├── stride.cpp │ ├── unique.cpp │ ├── CMakeLists.txt │ ├── split.cpp │ ├── sort.cpp │ ├── shuffle.cpp │ └── insert.cpp ├── CMakeLists.txt ├── view_facade.cpp ├── container_conversion.cpp └── to_container.cpp ├── install_libcxx.sh ├── include ├── range │ └── v3 │ │ ├── all.hpp │ │ ├── numeric.hpp │ │ ├── utility │ │ ├── meta.hpp │ │ ├── static_const.hpp │ │ ├── nullptr_v.hpp │ │ ├── integer_sequence.hpp │ │ ├── get.hpp │ │ ├── tagged_tuple.hpp │ │ ├── infinity.hpp │ │ ├── copy.hpp │ │ ├── iterator_traits.hpp │ │ └── optional.hpp │ │ ├── algorithm │ │ ├── tagspec.hpp │ │ ├── fill_n.hpp │ │ ├── generate_n.hpp │ │ ├── fill.hpp │ │ ├── aux_ │ │ │ ├── lower_bound_n.hpp │ │ │ └── upper_bound_n.hpp │ │ ├── copy_n.hpp │ │ ├── for_each.hpp │ │ ├── generate.hpp │ │ ├── lower_bound.hpp │ │ ├── all_of.hpp │ │ └── upper_bound.hpp │ │ ├── core.hpp │ │ ├── action.hpp │ │ ├── empty.hpp │ │ ├── front.hpp │ │ ├── at.hpp │ │ ├── back.hpp │ │ ├── range_for.hpp │ │ ├── view │ │ ├── filter.hpp │ │ ├── unbounded.hpp │ │ ├── empty.hpp │ │ └── unique.hpp │ │ ├── numeric │ │ └── iota.hpp │ │ ├── view.hpp │ │ └── getlines.hpp └── meta │ └── meta_fwd.hpp ├── example ├── CMakeLists.txt └── fibonacci.cpp ├── TODO.md ├── README.md └── SECURITY.md /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "doc/gh-pages"] 2 | path = doc/gh-pages 3 | url = https://github.com/ericniebler/range-v3.git 4 | branch = gh-pages 5 | -------------------------------------------------------------------------------- /perf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(counted_insertion_sort counted_insertion_sort.cpp) 2 | 3 | add_executable(sort_patterns sort_patterns.cpp) 4 | -------------------------------------------------------------------------------- /doc/std/show.cmd: -------------------------------------------------------------------------------- 1 | pandoc -f markdown_github+yaml_metadata_block+citations -t html -o D4128.html --filter pandoc-citeproc --csl=acm-sig-proceedings.csl --number-sections --toc -s -S --template=pandoc-template --include-before-body=header.html D4128.md 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.hpp text 2 | *.cpp text 3 | *.txt text 4 | *.html text 5 | *.md text 6 | *.yml text 7 | *.xml text 8 | *.in text 9 | .gitattributes text 10 | .gitignore text 11 | 12 | *.cmd -text 13 | *.sln -text 14 | *.vcxproj -text 15 | *.vcxproj.filters -text 16 | -------------------------------------------------------------------------------- /test/algorithm/is_heap1.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define IS_HEAP_1 14 | #include "./is_heap.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/is_heap2.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define IS_HEAP_2 14 | #include "./is_heap.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/is_heap3.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define IS_HEAP_3 14 | #include "./is_heap.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/is_heap4.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define IS_HEAP_4 14 | #include "./is_heap.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_union1.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_UNION_1 14 | #include "./set_union.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_union2.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_UNION_2 14 | #include "./set_union.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_union3.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_UNION_3 14 | #include "./set_union.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_union4.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_UNION_4 14 | #include "./set_union.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_union5.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_UNION_5 14 | #include "./set_union.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_union6.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_UNION_6 14 | #include "./set_union.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/is_heap_until1.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define IS_HEAP_UNTIL_1 14 | #include "./is_heap_until.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/is_heap_until2.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define IS_HEAP_UNTIL_2 14 | #include "./is_heap_until.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/is_heap_until3.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define IS_HEAP_UNTIL_3 14 | #include "./is_heap_until.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/is_heap_until4.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define IS_HEAP_UNTIL_4 14 | #include "./is_heap_until.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_difference1.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_DIFFERENCE_1 14 | #include "./set_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_difference2.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_DIFFERENCE_2 14 | #include "./set_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_difference3.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_DIFFERENCE_3 14 | #include "./set_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_difference4.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_DIFFERENCE_4 14 | #include "./set_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_difference5.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_DIFFERENCE_5 14 | #include "./set_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_difference6.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_DIFFERENCE_6 14 | #include "./set_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_intersection1.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_INTERSECTION_1 14 | #include "./set_intersection.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_intersection2.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_INTERSECTION_2 14 | #include "./set_intersection.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_intersection3.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_INTERSECTION_3 14 | #include "./set_intersection.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_intersection4.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_INTERSECTION_4 14 | #include "./set_intersection.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_intersection5.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_INTERSECTION_5 14 | #include "./set_intersection.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_intersection6.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_INTERSECTION_6 14 | #include "./set_intersection.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_symmetric_difference1.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_SYMMETRIC_DIFFERENCE_1 14 | #include "./set_symmetric_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_symmetric_difference2.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_SYMMETRIC_DIFFERENCE_2 14 | #include "./set_symmetric_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_symmetric_difference3.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_SYMMETRIC_DIFFERENCE_3 14 | #include "./set_symmetric_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_symmetric_difference4.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_SYMMETRIC_DIFFERENCE_4 14 | #include "./set_symmetric_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_symmetric_difference5.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_SYMMETRIC_DIFFERENCE_5 14 | #include "./set_symmetric_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/algorithm/set_symmetric_difference6.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #define SET_SYMMETRIC_DIFFERENCE_6 14 | #include "./set_symmetric_difference.hpp" 15 | -------------------------------------------------------------------------------- /test/multiple1.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include "./simple_test.hpp" 14 | #include "./test_utils.hpp" 15 | #include "./test_iterators.hpp" 16 | -------------------------------------------------------------------------------- /test/numeric/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(num.accumulate accumulate.cpp) 2 | add_test(test.num.accumulate num.accumulate) 3 | 4 | add_executable(num.adjacent_difference adjacent_difference.cpp) 5 | add_test(test.num.adjacent_difference num.adjacent_difference) 6 | 7 | add_executable(num.inner_product inner_product.cpp) 8 | add_test(test.num.inner_product num.inner_product) 9 | 10 | add_executable(num.iota iota.cpp) 11 | add_test(test.num.iota num.iota) 12 | 13 | add_executable(num.partial_sum partial_sum.cpp) 14 | add_test(test.num.partial_sum num.partial_sum) 15 | -------------------------------------------------------------------------------- /test/multiple2.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include "./simple_test.hpp" 14 | #include "./test_utils.hpp" 15 | #include "./test_iterators.hpp" 16 | 17 | int main() 18 | { 19 | return ::test_result(); 20 | } 21 | -------------------------------------------------------------------------------- /install_libcxx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Install libc++ under travis 4 | 5 | svn --quiet co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx 6 | mkdir libcxx/build 7 | (cd libcxx/build && cmake .. -DLIBCXX_CXX_ABI=libstdc++ -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.6;/usr/include/c++/4.6/x86_64-linux-gnu") 8 | make -C libcxx/build cxx -j2 9 | sudo cp libcxx/build/lib/libc++.so.1.0 /usr/lib/ 10 | sudo cp -r libcxx/build/include/c++/v1 /usr/include/c++/v1/ 11 | sudo ln -sf /usr/lib/libc++.so.1.0 /usr/lib/libc++.so 12 | sudo ln -sf /usr/lib/libc++.so.1.0 /usr/lib/libc++.so.1 13 | -------------------------------------------------------------------------------- /include/range/v3/all.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013,2014. 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_ALL_HPP 15 | #define RANGES_V3_ALL_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/range/v3/numeric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | /// \file numeric.hpp 3 | /// Contains range-based versions of the numeric algorithms 4 | // 5 | // Copyright Eric Niebler 2014 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See 8 | // accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | 11 | #ifndef RANGES_V3_NUMERIC_HPP 12 | #define RANGES_V3_NUMERIC_HPP 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/range/v3/utility/meta.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_META_HPP 15 | #define RANGES_V3_UTILITY_META_HPP 16 | 17 | #if defined(__GNUC__) || defined(__clang__) 18 | # pragma message "This header is deprecated. Please use: meta/meta.hpp" 19 | #endif 20 | 21 | #include 22 | #include 23 | 24 | namespace ranges 25 | { 26 | inline namespace v3 27 | { 28 | namespace meta = ::meta::v1; 29 | } 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /test/istream_range.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "simple_test.hpp" 5 | #include "test_utils.hpp" 6 | 7 | struct moveonly 8 | { 9 | char c; 10 | 11 | moveonly() = default; 12 | moveonly(moveonly &&) = default; 13 | moveonly& operator=(moveonly &&) & = default; 14 | 15 | operator char() const 16 | { 17 | return c; 18 | } 19 | friend std::istream &operator>>(std::istream &is, moveonly &m) 20 | { 21 | is.get(m.c); 22 | return is; 23 | } 24 | }; 25 | 26 | int main() 27 | { 28 | static const char test[] = "abcd3210"; 29 | std::istringstream ss{test}; 30 | ::check_equal(ranges::istream(ss), 31 | ranges::make_range(test, test + sizeof(test) - 1)); 32 | return ::test_result(); 33 | } 34 | -------------------------------------------------------------------------------- /test/getlines.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include "./simple_test.hpp" 15 | #include "./test_utils.hpp" 16 | 17 | int main() 18 | { 19 | std::stringstream sin{ 20 | R"(Now is 21 | the time 22 | for all 23 | good men 24 | )"}; 25 | 26 | ::check_equal(ranges::getlines(sin), {"Now is", "the time", "for all", "good men"}); 27 | 28 | using Rng = decltype(ranges::getlines(sin)); 29 | CONCEPT_ASSERT(ranges::InputView()); 30 | CONCEPT_ASSERT(!ranges::ForwardView()); 31 | 32 | return ::test_result(); 33 | } 34 | -------------------------------------------------------------------------------- /test/utility/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_executable(utility.basic_iterator basic_iterator.cpp) 3 | add_test(test.utility.basic_iterator utility.basic_iterator) 4 | 5 | add_executable(utility.concepts concepts.cpp) 6 | add_test(test.utility.concepts utility.concepts) 7 | 8 | add_executable(utility.common_type common_type.cpp) 9 | add_test(test.utility.common_type utility.common_type) 10 | 11 | add_executable(utility.functional functional.cpp) 12 | add_test(test.utility.functional utility.functional) 13 | 14 | add_executable(utility.iterator iterator.cpp) 15 | add_test(test.utility.iterator utility.iterator) 16 | 17 | add_executable(utility.reverse_iterator reverse_iterator.cpp) 18 | add_test(test.utility.reverse_iterator utility.reverse_iterator) 19 | 20 | add_executable(utility.swap swap.cpp) 21 | add_test(test.utility.swap utility.swap) 22 | 23 | add_executable(utility.meta meta.cpp) 24 | add_test(test.utility.meta utility.meta) 25 | -------------------------------------------------------------------------------- /test/view/repeat.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "../simple_test.hpp" 17 | #include "../test_utils.hpp" 18 | 19 | int main() 20 | { 21 | using namespace ranges; 22 | auto rng = view::repeat(9) | view::take(10); 23 | ::models(rng); 24 | ::models(rng); 25 | ::models(rng.begin()); 26 | ::check_equal(rng, {9, 9, 9, 9, 9, 9, 9, 9, 9, 9}); 27 | 28 | return test_result(); 29 | } 30 | -------------------------------------------------------------------------------- /test/view/indirect.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "../simple_test.hpp" 17 | #include "../test_utils.hpp" 18 | 19 | int main() 20 | { 21 | using namespace ranges; 22 | std::vector> vp; 23 | for(int i = 0; i < 10; ++i) 24 | vp.push_back(std::make_shared(i)); 25 | auto && rng = vp | view::indirect; 26 | CHECK(&*begin(rng) == vp[0].get()); 27 | ::check_equal(rng, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); 28 | 29 | return test_result(); 30 | } 31 | -------------------------------------------------------------------------------- /test/utility/iterator.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | #include "../test_utils.hpp" 17 | 18 | using namespace ranges; 19 | 20 | void test_insert_iterator() 21 | { 22 | CONCEPT_ASSERT(WeakOutputIterator>, int&&>()); 23 | std::vector vi{5,6,7,8}; 24 | copy({1,2,3,4}, inserter(vi, vi.begin()+2)); 25 | ::check_equal(vi, {5,6,1,2,3,4,7,8}); 26 | } 27 | 28 | int main() 29 | { 30 | test_insert_iterator(); 31 | 32 | return ::test_result(); 33 | } 34 | -------------------------------------------------------------------------------- /include/range/v3/utility/static_const.hpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2013-2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | #ifndef RANGES_V3_UTILITY_STATIC_CONST_HPP 14 | #define RANGES_V3_UTILITY_STATIC_CONST_HPP 15 | 16 | #include 17 | 18 | namespace ranges 19 | { 20 | inline namespace v3 21 | { 22 | /// \ingroup group-utility 23 | template 24 | struct static_const 25 | { 26 | static constexpr T value {}; 27 | }; 28 | 29 | /// \ingroup group-utility 30 | /// \sa `static_const` 31 | template 32 | constexpr T static_const::value; 33 | } 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/range/v3/utility/nullptr_v.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013,2014. 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_NULLVAL_HPP 15 | #define RANGES_V3_UTILITY_NULLVAL_HPP 16 | 17 | #include 18 | 19 | namespace ranges 20 | { 21 | inline namespace v3 22 | { 23 | /// \ingroup group-utility 24 | template 25 | constexpr T *_nullptr_v() 26 | { 27 | return nullptr; 28 | } 29 | 30 | #if RANGES_CXX_VARIABLE_TEMPLATES 31 | /// \ingroup group-utility 32 | template 33 | constexpr T *nullptr_v = nullptr; 34 | #endif 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /include/range/v3/utility/integer_sequence.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_INTEGER_SEQUENCE_HPP 15 | #define RANGES_V3_UTILITY_INTEGER_SEQUENCE_HPP 16 | 17 | #if defined(__GNUC__) || defined(__clang__) 18 | # pragma message "This header is deprecated. Please use: meta/meta.hpp" 19 | #endif 20 | 21 | #include 22 | #include 23 | 24 | namespace ranges 25 | { 26 | inline namespace v3 27 | { 28 | namespace meta = ::meta::v1; 29 | } 30 | 31 | using meta::integer_sequence; 32 | using meta::make_integer_sequence; 33 | 34 | using meta::index_sequence; 35 | using meta::make_index_sequence; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /doc/std/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 |
Document number: 5 | D4128=yy-nnnn 6 |
Date:2014-10-10
Project:Programming Language C++, Library Working Group
Reply-to: 19 | Eric Niebler <eniebler@boost.org>,
20 | Sean Parent <sparent@adobe.com>,
21 | Andrew Sutton <andrew.n.sutton@gmail.com> 22 |
25 | -------------------------------------------------------------------------------- /test/action/remove_if.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "../simple_test.hpp" 17 | #include "../test_utils.hpp" 18 | 19 | int main() 20 | { 21 | using namespace ranges; 22 | 23 | std::vector v = view::ints(1,21); 24 | auto & v2 = action::remove_if(v, [](int i){return i % 2 == 0;}); 25 | CHECK(&v2 == &v); 26 | check_equal(v, {1,3,5,7,9,11,13,15,17,19}); 27 | 28 | auto && v3 = v | move | action::remove_if(std::bind(std::less{}, std::placeholders::_1, 10)); 29 | check_equal(v3, {11,13,15,17,19}); 30 | 31 | return ::test_result(); 32 | } 33 | -------------------------------------------------------------------------------- /example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(comprehensions comprehensions.cpp) 2 | add_test(test.example.comprehensions, comprehensions) 3 | 4 | add_executable(fibonacci fibonacci.cpp) 5 | add_test(test.example.fibonacci, fibonacci) 6 | 7 | #add_executable(n_queens n_queens.cpp) 8 | #add_test(test.example.n_queens, n_queens) 9 | #set_target_properties(n_queens PROPERTIES COMPILE_FLAGS "-std=gnu++14") 10 | 11 | # Guarded with a variable because: 12 | # (a) The calendar example causes gcc to puke, and 13 | # (b) It requires a fix for Boost.Range(!!!) that is 14 | # currently only available on the develop branch. 15 | if(RANGES_BUILD_CALENDAR_EXAMPLE) 16 | set(Boost_USE_STATIC_LIBS ON) 17 | set(Boost_USE_MULTITHREADED ON) 18 | set(Boost_USE_STATIC_RUNTIME OFF) 19 | find_package(Boost 1.59 COMPONENTS date_time program_options) 20 | 21 | if (Boost_FOUND) 22 | include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) 23 | add_executable(calendar calendar.cpp) 24 | target_link_libraries(calendar ${Boost_LIBRARIES}) 25 | endif() 26 | endif() 27 | -------------------------------------------------------------------------------- /test/action/drop.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | #include "../test_utils.hpp" 17 | 18 | int main() 19 | { 20 | using namespace ranges; 21 | 22 | std::vector v = view::ints(1,21); 23 | auto & v2 = action::drop(v, 3); 24 | CHECK(&v2 == &v); 25 | CHECK(v.size() == 17u); 26 | CHECK(v[0] == 4); 27 | 28 | v = std::move(v) | action::drop(3); 29 | CHECK(v.size() == 14u); 30 | CHECK(v[0] == 7); 31 | 32 | v |= action::drop(3); 33 | CHECK(v.size() == 11u); 34 | CHECK(v[0] == 10); 35 | 36 | v |= action::drop(100); 37 | CHECK(v.size() == 0u); 38 | 39 | return ::test_result(); 40 | } 41 | -------------------------------------------------------------------------------- /test/action/transform.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "../simple_test.hpp" 19 | #include "../test_utils.hpp" 20 | 21 | int main() 22 | { 23 | using namespace ranges; 24 | 25 | std::vector v = view::ints(0,10); 26 | 27 | auto v0 = v | copy | action::transform([](int i){return i*i;}); 28 | ::models(v, v0); 29 | ::check_equal(v0, {0,1,4,9,16,25,36,49,64,81}); 30 | 31 | action::transform(v, [](int i){return i*i;}); 32 | ::check_equal(v, {0,1,4,9,16,25,36,49,64,81}); 33 | 34 | return ::test_result(); 35 | } 36 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(action) 2 | add_subdirectory(algorithm) 3 | add_subdirectory(numeric) 4 | add_subdirectory(utility) 5 | add_subdirectory(view) 6 | 7 | add_executable(container_conversion container_conversion.cpp) 8 | add_test(test.container_conversion container_conversion) 9 | 10 | add_executable(constexpr_core constexpr_core.cpp) 11 | add_test(test.constexpr_core constexpr_core) 12 | 13 | add_executable(view_facade view_facade.cpp) 14 | add_test(test.view_facade view_facade) 15 | 16 | add_executable(view_adaptor view_adaptor.cpp) 17 | add_test(test.view_adaptor view_adaptor) 18 | 19 | add_executable(range range.cpp) 20 | add_test(test.range range) 21 | 22 | add_executable(multiple multiple1.cpp multiple2.cpp) 23 | add_test(test.multiple multiple) 24 | 25 | add_executable(distance distance.cpp) 26 | add_test(test.distance distance) 27 | 28 | add_executable(to_container to_container.cpp) 29 | add_test(test.to_container, to_container) 30 | 31 | add_executable(getlines getlines.cpp) 32 | add_test(test.getlines, getlines) 33 | 34 | add_executable(istream_range istream_range.cpp) 35 | add_test(test.istream_range, istream_range) 36 | -------------------------------------------------------------------------------- /test/action/take.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | #include "../test_utils.hpp" 17 | 18 | int main() 19 | { 20 | using namespace ranges; 21 | 22 | std::vector v = view::ints(1,21); 23 | auto & v2 = action::take(v, 17); 24 | CHECK(&v2 == &v); 25 | CHECK(v.size() == 17u); 26 | CHECK(v.back() == 17); 27 | 28 | v = std::move(v) | action::take(14); 29 | CHECK(v.size() == 14u); 30 | CHECK(v.back() == 14); 31 | 32 | v |= action::take(11); 33 | CHECK(v.size() == 11u); 34 | CHECK(v.back() == 11); 35 | 36 | v |= action::take(100); 37 | CHECK(v.size() == 11u); 38 | 39 | v |= action::take(0); 40 | CHECK(v.size() == 0u); 41 | 42 | return ::test_result(); 43 | } 44 | -------------------------------------------------------------------------------- /test/view/unique.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "../simple_test.hpp" 17 | #include "../test_utils.hpp" 18 | #include 19 | 20 | int main() 21 | { 22 | using namespace ranges; 23 | 24 | int rgi[] = {1, 1, 1, 2, 3, 4, 4}; 25 | std::vector out; 26 | 27 | auto && rng = rgi | view::unique; 28 | has_type(*begin(rng)); 29 | models(rng); 30 | models_not(rng); 31 | models(begin(rng)); 32 | models_not(begin(rng)); 33 | copy(rng, ranges::back_inserter(out)); 34 | ::check_equal(out, {1, 2, 3, 4}); 35 | 36 | return test_result(); 37 | } 38 | -------------------------------------------------------------------------------- /include/range/v3/algorithm/tagspec.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2015 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | 13 | #ifndef RANGES_V3_ALGORITHM_TAGSPEC_HPP 14 | #define RANGES_V3_ALGORITHM_TAGSPEC_HPP 15 | 16 | #include 17 | #include 18 | 19 | namespace ranges 20 | { 21 | inline namespace v3 22 | { 23 | RANGES_DEFINE_TAG_SPECIFIER(in) 24 | RANGES_DEFINE_TAG_SPECIFIER(in1) 25 | RANGES_DEFINE_TAG_SPECIFIER(in2) 26 | RANGES_DEFINE_TAG_SPECIFIER(out) 27 | RANGES_DEFINE_TAG_SPECIFIER(out1) 28 | RANGES_DEFINE_TAG_SPECIFIER(out2) 29 | RANGES_DEFINE_TAG_SPECIFIER(fun) 30 | RANGES_DEFINE_TAG_SPECIFIER(min) 31 | RANGES_DEFINE_TAG_SPECIFIER(max) 32 | RANGES_DEFINE_TAG_SPECIFIER(begin) 33 | RANGES_DEFINE_TAG_SPECIFIER(end) 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/range/v3/utility/get.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_GET_HPP 15 | #define RANGES_V3_UTILITY_GET_HPP 16 | 17 | #include 18 | #include 19 | 20 | namespace ranges 21 | { 22 | inline namespace v3 23 | { 24 | /// \addtogroup group-utility Utility 25 | /// @{ 26 | /// 27 | template 28 | T & get(meta::id_t & value) 29 | { 30 | return value; 31 | } 32 | 33 | template 34 | T const & get(meta::id_t const & value) 35 | { 36 | return value; 37 | } 38 | 39 | template 40 | T && get(meta::id_t && value) 41 | { 42 | return std::move(value); 43 | } 44 | /// @} 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/range/v3/core.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_CORE_HPP 15 | #define RANGES_V3_CORE_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /test/action/drop_while.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | #include "../test_utils.hpp" 17 | 18 | int main() 19 | { 20 | using namespace ranges; 21 | using namespace std::placeholders; 22 | 23 | std::vector v = view::ints(1,21); 24 | auto & v2 = action::drop_while(v, std::bind(std::less(), _1, 4)); 25 | CHECK(&v2 == &v); 26 | CHECK(v.size() == 17u); 27 | CHECK(v[0] == 4); 28 | 29 | v = std::move(v) | action::drop_while([](int i){return i < 7;}); 30 | CHECK(v.size() == 14u); 31 | CHECK(v[0] == 7); 32 | 33 | v |= action::drop_while([](int i){return i < 10;}); 34 | CHECK(v.size() == 11u); 35 | CHECK(v[0] == 10); 36 | 37 | v |= action::drop_while([](int){return true;}); 38 | CHECK(v.size() == 0u); 39 | 40 | return ::test_result(); 41 | } 42 | -------------------------------------------------------------------------------- /test/algorithm/adjacent_find.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include "../simple_test.hpp" 15 | 16 | int main() 17 | { 18 | int v1[] = { 0, 2, 2, 4, 6 }; 19 | CHECK(ranges::adjacent_find(ranges::begin(v1), ranges::end(v1)) == &v1[1]); 20 | CHECK(ranges::adjacent_find(v1) == &v1[1]); 21 | 22 | std::pair v2[] = {{0, 0}, {0, 2}, {0, 2}, {0, 4}, {0, 6}}; 23 | CHECK(ranges::adjacent_find(ranges::begin(v2), ranges::end(v2), 24 | ranges::equal_to{}, &std::pair::second) == &v2[1]); 25 | CHECK(ranges::adjacent_find(v2, ranges::equal_to{}, &std::pair::second) == &v2[1]); 26 | static_assert(std::is_same*, 27 | decltype(ranges::adjacent_find(v2, ranges::equal_to{}, 28 | &std::pair::second))>::value, ""); 29 | return test_result(); 30 | } 31 | -------------------------------------------------------------------------------- /include/range/v3/action.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_ACTION_HPP 15 | #define RANGES_V3_ACTION_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /test/action/cont_concepts.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | #include "../test_utils.hpp" 17 | 18 | int main() 19 | { 20 | using namespace ranges; 21 | 22 | int rgi[6]; 23 | ::models(rgi); 24 | ::models_not(rgi); 25 | 26 | std::array a; 27 | ::models(a); 28 | ::models_not(a); 29 | 30 | std::vector v; 31 | ::models(v); 32 | 33 | std::vector> v2; 34 | ::models(v2); 35 | 36 | ::models(v2); 37 | ::models_not(std::move(v2)); 38 | 39 | ::models(ranges::ref(v2)); 40 | ::models(std::ref(v2)); 41 | 42 | return ::test_result(); 43 | } 44 | -------------------------------------------------------------------------------- /example/fibonacci.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | // 12 | 13 | // This example shows how to define a range that is implemented 14 | // in terms of itself. The example is generating the Fibonacci 15 | // sequence using self-reference and zip_with. 16 | // 17 | // Note: don't use recursive_range_fn in performance sensitive 18 | // code. Self-reference comes with indirection and dynamic 19 | // allocation overhead. 20 | 21 | #include 22 | #include 23 | #include "./recursive_range.hpp" 24 | 25 | int main() 26 | { 27 | using namespace ranges::view; 28 | 29 | // Define a nullary function fibs that returns an infinite range 30 | // that generates the Fibonacci sequence. 31 | ranges::ext::recursive_range_fn const fibs {[&]{ 32 | return concat(closed_ints(0,1), zip_with(std::plus{}, fibs(), tail(fibs()))); 33 | }}; 34 | 35 | auto x = take(fibs(), 20); 36 | ranges::for_each(x, [](int i) 37 | { 38 | std::cout << i << std::endl; 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /test/action/slice.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "../simple_test.hpp" 20 | #include "../test_utils.hpp" 21 | 22 | int main() 23 | { 24 | using namespace ranges; 25 | 26 | std::vector v = view::ints(0,100); 27 | 28 | auto v2 = v | copy | action::slice(10,20); 29 | CHECK(size(v2) == 10u); 30 | ::models(v, v2); 31 | ::check_equal(v2, {10,11,12,13,14,15,16,17,18,19}); 32 | 33 | v2 = v2 | move | action::slice(2,8); 34 | ::check_equal(v2, {12,13,14,15,16,17}); 35 | 36 | v2 |= action::slice(0,0); 37 | CHECK(v2.size() == 0u); 38 | 39 | auto & v3 = action::slice(v, 90, 100); 40 | CHECK(&v3 == &v); 41 | ::check_equal(v, {90,91,92,93,94,95,96,97,98,99}); 42 | 43 | return ::test_result(); 44 | } 45 | -------------------------------------------------------------------------------- /test/view/tokenize.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../simple_test.hpp" 4 | #include "../test_utils.hpp" 5 | 6 | int main() 7 | { 8 | using namespace ranges; 9 | 10 | std::string txt{"abc\ndef\tghi"}; 11 | const std::regex rx{R"delim(([\w]+))delim"}; 12 | auto&& rng = txt | view::tokenize(rx,1); 13 | const auto& crng = txt | view::tokenize(rx,1); 14 | 15 | ::check_equal(rng, {"abc","def","ghi"}); 16 | ::check_equal(crng, {"abc","def","ghi"}); 17 | 18 | ::has_type&>(*ranges::begin(rng)); 19 | ::has_type&>(*ranges::begin(crng)); 20 | 21 | ::models(rng); 22 | ::models(rng); 23 | ::models_not(rng); 24 | ::models_not(rng); 25 | ::models_not(rng); 26 | 27 | ::models(crng); 28 | ::models(crng); 29 | ::models_not(crng); 30 | ::models_not(crng); 31 | ::models_not(crng); 32 | 33 | // ::models(rng); 34 | // ::models(crng); 35 | 36 | return test_result(); 37 | } 38 | -------------------------------------------------------------------------------- /test/action/take_while.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | #include "../test_utils.hpp" 17 | 18 | int main() 19 | { 20 | using namespace ranges; 21 | using namespace std::placeholders; 22 | 23 | std::vector v = view::ints(1,21); 24 | auto & v2 = action::take_while(v, std::bind(std::less(), _1, 18)); 25 | CHECK(&v2 == &v); 26 | CHECK(v.size() == 17u); 27 | CHECK(v.back() == 17); 28 | 29 | v = std::move(v) | action::take_while([](int i){return i < 15;}); 30 | CHECK(v.size() == 14u); 31 | CHECK(v.back() == 14); 32 | 33 | v |= action::take_while([](int i){return i < 12;}); 34 | CHECK(v.size() == 11u); 35 | CHECK(v.back() == 11); 36 | 37 | v |= action::take_while([](int){return true;}); 38 | CHECK(v.size() == 11u); 39 | 40 | v |= action::take_while([](int){return false;}); 41 | CHECK(v.size() == 0u); 42 | 43 | return ::test_result(); 44 | } 45 | -------------------------------------------------------------------------------- /test/view/delimit.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "../simple_test.hpp" 18 | #include "../test_utils.hpp" 19 | 20 | int main() 21 | { 22 | using namespace ranges; 23 | 24 | auto rng0 = view::iota(10) | view::delimit(25); 25 | ::check_equal(rng0, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}); 26 | ::models(rng0); 27 | ::models_not(rng0); 28 | ::models(rng0.begin()); 29 | CONCEPT_ASSERT(RandomAccessView, int>>()); 30 | 31 | std::vector vi{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 32 | auto rng1 = vi | view::delimit(50); 33 | ::check_equal(rng1, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); 34 | 35 | auto rng2 = view::delimit(vi.begin(), 8); 36 | ::check_equal(rng2, {0, 1, 2, 3, 4, 5, 6, 7}); 37 | 38 | return test_result(); 39 | } 40 | -------------------------------------------------------------------------------- /test/view/all.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "../simple_test.hpp" 17 | #include "../test_utils.hpp" 18 | 19 | int main() 20 | { 21 | using namespace ranges; 22 | 23 | int rgi[] = {1, 1, 1, 2, 3, 4, 4}; 24 | std::vector vi(begin(rgi), end(rgi)); 25 | std::list li(begin(rgi), end(rgi)); 26 | 27 | range x = view::all(rgi); 28 | range::iterator> y = view::all(vi); 29 | sized_range::iterator> z = view::all(li); 30 | 31 | x = view::all(x); 32 | y = view::all(y); 33 | z = view::all(z); 34 | 35 | CHECK(x.size() == 7u); 36 | CHECK(y.size() == 7u); 37 | CHECK(z.size() == 7u); 38 | 39 | ranges::reference_wrapper rrgi = view::all(std::ref(rgi)); 40 | auto stdref = std::ref(rgi); 41 | rrgi = view::all(stdref); 42 | rrgi = view::all(static_cast const &>(stdref)); 43 | 44 | return test_result(); 45 | } 46 | -------------------------------------------------------------------------------- /test/action/stride.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "../simple_test.hpp" 19 | #include "../test_utils.hpp" 20 | 21 | int main() 22 | { 23 | using namespace ranges; 24 | 25 | std::vector v = view::ints(0,100); 26 | 27 | auto v2 = v | copy | action::stride(10); 28 | CHECK(size(v2) == 10u); 29 | ::models(v, v2); 30 | ::check_equal(v2, {0,10,20,30,40,50,60,70,80,90}); 31 | 32 | v2 = v2 | move | action::stride(4); 33 | ::check_equal(v2, {0,40,80}); 34 | 35 | v2 |= action::stride(2); 36 | ::check_equal(v2, {0,80}); 37 | v2 |= action::stride(1); 38 | ::check_equal(v2, {0,80}); 39 | v2 |= action::stride(10); 40 | ::check_equal(v2, {0}); 41 | 42 | auto & v3 = action::stride(v, 30); 43 | CHECK(&v3 == &v); 44 | ::check_equal(v, {0,30,60,90}); 45 | 46 | return ::test_result(); 47 | } 48 | -------------------------------------------------------------------------------- /test/action/unique.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "../simple_test.hpp" 24 | #include "../test_utils.hpp" 25 | 26 | int main() 27 | { 28 | using namespace ranges; 29 | std::mt19937 gen; 30 | 31 | // [1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,...] 32 | std::vector v = 33 | view::for_each(view::ints(1,100), [](int i){ 34 | return yield_from(view::repeat_n(i,i)); 35 | }); 36 | check_equal(view::take(v, 15), {1,2,2,3,3,3,4,4,4,4,5,5,5,5,5}); 37 | v |= action::shuffle(gen); 38 | CHECK(!is_sorted(v)); 39 | 40 | v |= action::sort | action::unique; 41 | CHECK(equal(v, view::ints(1,100))); 42 | 43 | return ::test_result(); 44 | } 45 | -------------------------------------------------------------------------------- /test/view/keys_value.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "../simple_test.hpp" 17 | #include "../test_utils.hpp" 18 | 19 | int main() 20 | { 21 | using namespace ranges; 22 | std::map m = { 23 | {"this", 0}, 24 | {"that", 1}, 25 | {"other", 2}}; 26 | auto && keys = m | view::keys; 27 | has_type(*begin(keys)); 28 | models(keys); 29 | models(keys); 30 | models(begin(keys)); 31 | CHECK(&*begin(keys) == &m.begin()->first); 32 | ::check_equal(keys, {"other", "that", "this"}); 33 | 34 | auto && values = m | view::values; 35 | has_type(*begin(values)); 36 | models(values); 37 | models(values); 38 | models(begin(values)); 39 | CHECK(&*begin(values) == &m.begin()->second); 40 | ::check_equal(values, {2, 1, 0}); 41 | 42 | return test_result(); 43 | } 44 | -------------------------------------------------------------------------------- /include/range/v3/empty.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_EMPTY_HPP 15 | #define RANGES_V3_EMPTY_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace ranges 23 | { 24 | inline namespace v3 25 | { 26 | /// \ingroup group-core 27 | struct empty_fn 28 | { 29 | /// \return `begin(rng) == end(rng)` 30 | template::value)> 33 | #else 34 | CONCEPT_REQUIRES_(Range())> 35 | #endif 36 | RANGES_CXX14_CONSTEXPR 37 | bool operator()(Rng &&rng) const 38 | { 39 | return begin(rng) == end(rng); 40 | } 41 | }; 42 | 43 | /// \ingroup group-core 44 | /// \sa `empty_fn` 45 | namespace 46 | { 47 | constexpr auto&& empty = static_const::value; 48 | } 49 | } 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /test/view/generate_n.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include "../simple_test.hpp" 15 | #include "../test_utils.hpp" 16 | 17 | namespace view = ranges::view; 18 | 19 | int main() 20 | { 21 | // Test for constant generator functions 22 | { 23 | int i = 0, j = 1; 24 | auto fib = view::generate_n([&]()->int{int tmp = i; i += j; std::swap(i, j); return tmp;}, 10); 25 | CONCEPT_ASSERT(ranges::InputView()); 26 | check_equal(fib, {0,1,1,2,3,5,8,13,21,34}); 27 | } 28 | 29 | // Test for mutable-only generator functions 30 | { 31 | int i = 0, j = 1; 32 | auto fib = view::generate_n([=]()mutable->int{int tmp = i; i += j; std::swap(i, j); return tmp;}, 10); 33 | CONCEPT_ASSERT(ranges::InputView()); 34 | check_equal(fib, {0,1,1,2,3,5,8,13,21,34}); 35 | // The generator cannot be called when it's const-qualified, so "fib const" 36 | // does not model View. 37 | CONCEPT_ASSERT(!ranges::View()); 38 | } 39 | 40 | return test_result(); 41 | } 42 | -------------------------------------------------------------------------------- /test/action/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(act.concepts cont_concepts.cpp) 2 | add_test(test.act.concepts act.concepts) 3 | 4 | add_executable(act.drop drop.cpp) 5 | add_test(test.act.drop act.drop) 6 | 7 | add_executable(act.drop_while drop_while.cpp) 8 | add_test(test.act.drop_while act.drop_while) 9 | 10 | add_executable(act.insert insert.cpp) 11 | add_test(test.act.insert act.insert) 12 | 13 | add_executable(act.push_front push_front.cpp) 14 | add_test(test.act.push_front act.push_front) 15 | 16 | add_executable(act.push_back push_back.cpp) 17 | add_test(test.act.push_back act.push_back) 18 | 19 | add_executable(act.remove_if remove_if.cpp) 20 | add_test(test.act.remove_if act.remove_if) 21 | 22 | add_executable(act.shuffle shuffle.cpp) 23 | add_test(test.act.shuffle act.shuffle) 24 | 25 | add_executable(act.slice slice.cpp) 26 | add_test(test.act.slice act.slice) 27 | 28 | add_executable(act.sort sort.cpp) 29 | add_test(test.act.sort act.sort) 30 | 31 | add_executable(act.split split.cpp) 32 | add_test(test.act.split act.split) 33 | 34 | add_executable(act.stride stride.cpp) 35 | add_test(test.act.stride act.stride) 36 | 37 | add_executable(act.take take.cpp) 38 | add_test(test.act.take act.take) 39 | 40 | add_executable(act.take_while take_while.cpp) 41 | add_test(test.act.take_while act.take_while) 42 | 43 | add_executable(act.transform transform.cpp) 44 | add_test(test.act.transform act.transform) 45 | 46 | add_executable(act.unique unique.cpp) 47 | add_test(test.act.unique act.unique) 48 | -------------------------------------------------------------------------------- /test/view/generate.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | #include "../test_utils.hpp" 17 | 18 | namespace view = ranges::view; 19 | 20 | int main() 21 | { 22 | // Test for constant generator functions 23 | { 24 | int i = 0, j = 1; 25 | auto fib = view::generate([&]()->int{int tmp = i; i += j; std::swap(i, j); return tmp;}); 26 | CONCEPT_ASSERT(ranges::InputView()); 27 | check_equal(fib | view::take(10), {0,1,1,2,3,5,8,13,21,34}); 28 | } 29 | 30 | // Test for mutable-only generator functions 31 | { 32 | int i = 0, j = 1; 33 | auto fib = view::generate([=]()mutable->int{int tmp = i; i += j; std::swap(i, j); return tmp;}); 34 | CONCEPT_ASSERT(ranges::InputView()); 35 | check_equal(fib | view::take(10), {0,1,1,2,3,5,8,13,21,34}); 36 | // The generator cannot be called when it's const-qualified, so "fib const" 37 | // does not model View. 38 | CONCEPT_ASSERT(!ranges::View()); 39 | } 40 | 41 | return test_result(); 42 | } 43 | -------------------------------------------------------------------------------- /include/range/v3/front.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_FRONT_HPP 15 | #define RANGES_V3_FRONT_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace ranges 25 | { 26 | inline namespace v3 27 | { 28 | /// \ingroup group-core 29 | struct front_fn 30 | { 31 | /// \return `*begin(rng)` 32 | template::value)> 35 | #else 36 | CONCEPT_REQUIRES_(Range())> 37 | #endif 38 | RANGES_CXX14_CONSTEXPR 39 | range_reference_t operator()(Rng &&rng) const 40 | { 41 | return *begin(rng); 42 | } 43 | }; 44 | 45 | /// \ingroup group-core 46 | /// \sa `front_fn` 47 | namespace 48 | { 49 | constexpr auto&& front = static_const::value; 50 | } 51 | } 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /test/algorithm/for_each.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | 17 | struct S 18 | { 19 | void p() const { *p_ += i_; } 20 | int *p_; 21 | int i_; 22 | }; 23 | 24 | int main() 25 | { 26 | int sum = 0; 27 | auto fun = [&](int i){sum += i; }; 28 | std::vector v1 { 0, 2, 4, 6 }; 29 | CHECK(ranges::for_each(v1.begin(), v1.end(), fun) == v1.end()); 30 | CHECK(ranges::for_each(v1, fun) == v1.end()); 31 | CHECK(sum == 24); 32 | 33 | sum = 0; 34 | auto rfun = [&](int & i){sum += i; }; 35 | CHECK(ranges::for_each(v1.begin(), v1.end(), rfun) == v1.end()); 36 | CHECK(ranges::for_each(v1, rfun) == v1.end()); 37 | CHECK(sum == 24); 38 | 39 | sum = 0; 40 | std::vector v2{{&sum, 0}, {&sum, 2}, {&sum, 4}, {&sum, 6}}; 41 | CHECK(ranges::for_each(v2.begin(), v2.end(), &S::p) == v2.end()); 42 | CHECK(ranges::for_each(v2, &S::p) == v2.end()); 43 | CHECK(sum == 24); 44 | 45 | sum = 0; 46 | CHECK(ranges::for_each(ranges::make_range(v1.begin(), v1.end()), fun).get_unsafe() == v1.end()); 47 | CHECK(sum == 12); 48 | 49 | return ::test_result(); 50 | } 51 | -------------------------------------------------------------------------------- /include/range/v3/at.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_AT_HPP 15 | #define RANGES_V3_AT_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace ranges 25 | { 26 | inline namespace v3 27 | { 28 | /// \ingroup group-core 29 | struct at_fn 30 | { 31 | /// \return `begin(rng)[n]` 32 | template::value)> 35 | #else 36 | CONCEPT_REQUIRES_(RandomAccessRange())> 37 | #endif 38 | RANGES_CXX14_CONSTEXPR 39 | auto operator()(Rng &&rng, range_difference_t n) const -> 40 | decltype(begin(rng)[n]) 41 | { 42 | return begin(rng)[n]; 43 | } 44 | }; 45 | 46 | /// \ingroup group-core 47 | /// \sa `at_fn` 48 | namespace 49 | { 50 | constexpr auto&& at = static_const::value; 51 | } 52 | } 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/range/v3/back.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_BACK_HPP 15 | #define RANGES_V3_BACK_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace ranges 25 | { 26 | inline namespace v3 27 | { 28 | /// \ingroup group-core 29 | struct back_fn 30 | { 31 | /// \return `*prev(end(rng))` 32 | template::value && BidirectionalRange::value)> 35 | #else 36 | CONCEPT_REQUIRES_(BoundedRange() && BidirectionalRange())> 37 | #endif 38 | RANGES_CXX14_CONSTEXPR 39 | range_reference_t operator()(Rng &&rng) const 40 | { 41 | return *prev(end(rng)); 42 | } 43 | }; 44 | 45 | /// \ingroup group-core 46 | /// \sa `back_fn` 47 | namespace 48 | { 49 | constexpr auto&& back = static_const::value; 50 | } 51 | } 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /test/algorithm/copy_backward.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "../simple_test.hpp" 18 | 19 | int main() 20 | { 21 | using ranges::begin; 22 | using ranges::end; 23 | using ranges::size; 24 | 25 | std::pair const a[] = {{0, 0}, {0, 1}, {1, 2}, {1, 3}, {3, 4}, {3, 5}}; 26 | static_assert(size(a) == 6, ""); 27 | std::pair out[size(a)] = {}; 28 | 29 | auto res = ranges::copy_backward(begin(a), end(a), end(out)); 30 | CHECK(res.first == end(a)); 31 | CHECK(res.second == begin(out)); 32 | CHECK(std::equal(a, a + size(a), out)); 33 | 34 | std::fill_n(out, size(out), std::make_pair(0, 0)); 35 | CHECK(!std::equal(a, a + size(a), out)); 36 | 37 | res = ranges::copy_backward(a, end(out)); 38 | CHECK(res.first == end(a)); 39 | CHECK(res.second == begin(out)); 40 | CHECK(std::equal(a, a + size(a), out)); 41 | 42 | std::fill_n(out, size(out), std::make_pair(0, 0)); 43 | auto res2 = ranges::copy_backward(ranges::view::all(a), end(out)); 44 | CHECK(res2.first.get_unsafe() == end(a)); 45 | CHECK(res2.second == begin(out)); 46 | CHECK(std::equal(a, a + size(a), out)); 47 | 48 | return test_result(); 49 | } 50 | -------------------------------------------------------------------------------- /test/view/move.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "../simple_test.hpp" 20 | #include "../test_utils.hpp" 21 | 22 | int main() 23 | { 24 | using namespace ranges; 25 | std::vector vs{"'allo", "'allo", "???"}; 26 | 27 | auto x = vs | view::move; 28 | CONCEPT_ASSERT(Same, concepts::BoundedView>()); 29 | CONCEPT_ASSERT(Same, concepts::SizedView>()); 30 | ::models(x); 31 | ::models(x); 32 | ::models(x.begin()); 33 | using I = decltype(x.begin()); 34 | CONCEPT_ASSERT(Same, concepts::RandomAccessIterator>()); 35 | CONCEPT_ASSERT(Same, ranges::random_access_iterator_tag>()); 36 | 37 | CHECK(std::strcmp((*x.begin()).c_str(), "'allo") == 0); 38 | 39 | std::vector vs2(x.begin(), x.end()); 40 | static_assert(std::is_same::value, ""); 41 | ::check_equal(vs2, {"'allo", "'allo", "???"}); 42 | ::check_equal(vs, {"", "", ""}); 43 | 44 | return test_result(); 45 | } 46 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | * Survey the use of projections. Do they only apply when evaluating predicates, or are they 2 | like full input transformations? (E.g, does `copy` get a projection parameter or not? Does the projection get applied by e.g. `set_difference`?) 3 | * Add contiguous iterator utilities. How about `is_contiguous_iterator` and `as_contiguous_range`: 4 | 5 | ``` 6 | template() && 8 | SizedIteratorRange() && 9 | is_contiguous_iterator())> 10 | range> *> 11 | as_contiguous_range(I begin, S end) 12 | { 13 | if(begin == end) 14 | return {nullptr, nullptr}; 15 | else 16 | return {addressof(*begin), addressof(*begin) + (end - begin)}; 17 | } 18 | ``` 19 | * Longer-term goals: 20 | - Make `inplace_merge` work with forward iterators 21 | - Make the sorting algorithms work with forward iterators 22 | - Study the impact of allowing ForwardIterator to return proxies 23 | 24 | * Maybe iterators are not necessarily countable. Is there a relation between 25 | the ability to be able to subtract two iterators to find the distance, and 26 | with the existence of a DistanceType associated type? Think of: 27 | - counted iterators (subtractable regardless of traversal category) 28 | - repeat_view iterators (*not* subtractable but could be random access otherwise) 29 | - infinite ranges (only countable with an infinite precision integer which we lack) 30 | 31 | * Add an optional extra argument to `view::join` for an element or sequence to be inserted 32 | between the joined sequences. 33 | -------------------------------------------------------------------------------- /include/range/v3/utility/tagged_tuple.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2015 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | 13 | #ifndef RANGES_V3_UTILITY_TAGGED_TUPLE_HPP 14 | #define RANGES_V3_UTILITY_TAGGED_TUPLE_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | namespace ranges 24 | { 25 | inline namespace v3 26 | { 27 | template 28 | using tagged_tuple = 29 | tagged...>, detail::tag_spec...>; 30 | 31 | #ifdef RANGES_WORKAROUND_MSVC_PACK_EXPANSION 32 | template 33 | struct tagged_tuple_helper { 34 | using type = Tag(bind_element_t); 35 | }; 36 | template 37 | constexpr tagged_tuple::type...> 38 | #else 39 | template 40 | constexpr tagged_tuple)...> 41 | #endif 42 | make_tagged_tuple(Ts &&... ts) 43 | { 44 | #ifdef RANGES_WORKAROUND_MSVC_PACK_EXPANSION 45 | return tagged_tuple::type...>{detail::forward(ts)...}; 46 | #else 47 | return tagged_tuple)...>{detail::forward(ts)...}; 48 | #endif 49 | } 50 | } 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /include/range/v3/range_for.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_RANGE_FOR_HPP 15 | #define RANGES_V3_RANGE_FOR_HPP 16 | 17 | #include 18 | #include 19 | 20 | #if RANGES_CXX_RANGE_BASED_FOR < RANGES_CXX_RANGE_BASED_FOR_17 21 | /// A range-based for macro, basically a hack until the build-in range-for can handle Ranges 22 | /// which have a different type for begin and end. 23 | /// \ingroup range-core 24 | #define RANGES_FOR(VAR_DECL, ...) \ 25 | if(bool _range_v3_done = false) {} \ 26 | else for(auto && _range_v3_rng = (__VA_ARGS__); !_range_v3_done;) \ 27 | for(auto _range_v3_begin = ranges::begin(_range_v3_rng); !_range_v3_done; \ 28 | _range_v3_done = true) \ 29 | for(auto _range_v3_end = ranges::end(_range_v3_rng); \ 30 | !_range_v3_done && _range_v3_begin != _range_v3_end; ++_range_v3_begin) \ 31 | if(!(_range_v3_done = true)) {} \ 32 | else for(VAR_DECL = *_range_v3_begin; _range_v3_done; _range_v3_done = false) \ 33 | /**/ 34 | 35 | #else 36 | #define RANGES_FOR(VAR_DECL, ...) for(VAR_DECL : (__VA_ARGS__)) 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /test/view/counted.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include "../simple_test.hpp" 16 | #include "../test_utils.hpp" 17 | #include "../test_iterators.hpp" 18 | 19 | int main() 20 | { 21 | using namespace ranges; 22 | std::cout << "\nTesting counted\n"; 23 | 24 | { 25 | int rgi[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 26 | auto rng = view::counted(forward_iterator{rgi}, 10); 27 | rng.size(); 28 | CONCEPT_ASSERT(SizedView()); 29 | auto i = rng.begin(); 30 | auto b = i.base(); 31 | auto c = i.count(); 32 | decltype(i) j{b, c}; 33 | ::check_equal(rng, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); 34 | static_assert(std::is_same>>::value, ""); 35 | } 36 | 37 | { 38 | std::list l; 39 | counted_iterator::iterator> a(l.begin(), 0); 40 | counted_iterator::const_iterator> b(l.begin(), 0); 41 | 42 | detail::ignore_unused( 43 | a-a, 44 | b-b, 45 | a-b, 46 | b-a); 47 | 48 | counted_iterator c(0,0); 49 | counted_iterator d(0,0); 50 | detail::ignore_unused( 51 | c-c, 52 | d-d, 53 | c-d, 54 | d-c); 55 | } 56 | 57 | return ::test_result(); 58 | } 59 | -------------------------------------------------------------------------------- /include/range/v3/utility/infinity.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_INFINITY_HPP 15 | #define RANGES_V3_UTILITY_INFINITY_HPP 16 | 17 | #include 18 | #include 19 | 20 | namespace ranges 21 | { 22 | inline namespace v3 23 | { 24 | /// \cond 25 | struct infinity 26 | { 27 | }; 28 | 29 | constexpr bool operator==(infinity, infinity) 30 | { 31 | return true; 32 | } 33 | constexpr bool operator!=(infinity, infinity) 34 | { 35 | return false; 36 | } 37 | 38 | template())> 40 | constexpr bool operator==(Integer, infinity) 41 | { 42 | return false; 43 | } 44 | template())> 46 | constexpr bool operator==(infinity, Integer) 47 | { 48 | return false; 49 | } 50 | template())> 52 | constexpr bool operator!=(Integer, infinity) 53 | { 54 | return true; 55 | } 56 | template())> 58 | constexpr bool operator!=(infinity, Integer) 59 | { 60 | return true; 61 | } 62 | /// \endcond 63 | } 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /test/view/partial_sum.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "../simple_test.hpp" 19 | #include "../test_utils.hpp" 20 | 21 | struct is_odd 22 | { 23 | bool operator()(int i) const 24 | { 25 | return (i % 2) == 1; 26 | } 27 | }; 28 | 29 | int main() 30 | { 31 | using namespace ranges; 32 | 33 | int rgi[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 34 | 35 | auto && rng = rgi | view::partial_sum(); 36 | has_type(*begin(rgi)); 37 | has_type(*begin(rng)); 38 | models(rng); 39 | models(rng); 40 | models_not(rng); 41 | ::check_equal(rng, {1, 3, 6, 10, 15, 21, 28, 36, 45, 55}); 42 | 43 | auto it = begin(rng); 44 | CHECK(*it == 1); 45 | auto it2 = next(it); 46 | CHECK(*it == 1); 47 | CHECK(*it2 == 3); 48 | it2 = it; 49 | CHECK(*it2 == 1); 50 | ++it2; 51 | CHECK(*it2 == 3); 52 | 53 | // Test partial_sum with a mutable lambda 54 | int cnt = 0; 55 | auto mutable_rng = view::partial_sum(rgi, [cnt](int i, int j) mutable { return i + j + cnt++;}); 56 | ::check_equal(mutable_rng, {1, 3, 7, 13, 21, 31, 43, 57, 73, 91}); 57 | CHECK(cnt == 0); 58 | CONCEPT_ASSERT(View()); 59 | CONCEPT_ASSERT(!View()); 60 | 61 | return test_result(); 62 | } 63 | -------------------------------------------------------------------------------- /doc/std/pandoc-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | $for(author-meta)$ 8 | 9 | $endfor$ 10 | $if(date-meta)$ 11 | 12 | $endif$ 13 | $if(title-prefix)$$title-prefix$ - $endif$$pagetitle$ 14 | 15 | $if(quotes)$ 16 | 17 | $endif$ 18 | $if(highlighting-css)$ 19 | 22 | $endif$ 23 | $for(css)$ 24 | 25 | $endfor$ 26 | $if(math)$ 27 | $math$ 28 | $endif$ 29 | $for(header-includes)$ 30 | $header-includes$ 31 | $endfor$ 32 | 33 | 34 | $for(include-before)$ 35 | $include-before$ 36 | $endfor$ 37 | $if(title)$ 38 |
39 |

$title$

40 | $if(subtitle)$ 41 |

$subtitle$

42 | $endif$ 43 | $for(author)$ 44 |

$author$

45 | $endfor$ 46 | $if(date)$ 47 |

$date$

48 | $endif$ 49 |
50 | $endif$ 51 |
52 |

“A beginning is the time for taking the most delicate care that the balances are correct.”

53 |

54 | – Frank Herbert, Dune 55 |

56 |
57 | $if(toc)$ 58 |
59 | $toc$ 60 |
61 | $endif$ 62 | $body$ 63 | $for(include-after)$ 64 | $include-after$ 65 | $endfor$ 66 | 67 | 68 | -------------------------------------------------------------------------------- /test/view/any_view.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "../simple_test.hpp" 19 | #include "../test_utils.hpp" 20 | 21 | int main() 22 | { 23 | using namespace ranges; 24 | 25 | any_view ints = view::ints; 26 | ::models(ints); 27 | ::models_not(ints); 28 | ::check_equal(ints | view::take(10), {0,1,2,3,4,5,6,7,8,9}); 29 | ::check_equal(ints | view::take(10), {0,1,2,3,4,5,6,7,8,9}); 30 | 31 | any_view ints2 = view::ints | view::take(10); 32 | ::models(ints2); 33 | ::models_not(ints2); 34 | ::check_equal(ints2, {0,1,2,3,4,5,6,7,8,9}); 35 | ::check_equal(ints2, {0,1,2,3,4,5,6,7,8,9}); 36 | 37 | any_random_access_view ints3 = view::ints | view::take(10); 38 | ::models(ints3); 39 | ::check_equal(ints3, {0,1,2,3,4,5,6,7,8,9}); 40 | ::check_equal(ints3, {0,1,2,3,4,5,6,7,8,9}); 41 | ::check_equal(aux::copy(ints3), {0,1,2,3,4,5,6,7,8,9}); 42 | ::check_equal(ints3 | view::reverse, {9,8,7,6,5,4,3,2,1,0}); 43 | 44 | any_view e; 45 | CHECK(e.begin() == e.begin()); 46 | CHECK(e.begin() == e.end()); 47 | 48 | range_iterator_t> i{},j{}; 49 | range_sentinel_t> k{}; 50 | CHECK(i == j); 51 | CHECK(i == k); 52 | 53 | return test_result(); 54 | } 55 | -------------------------------------------------------------------------------- /include/range/v3/algorithm/fill_n.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | #ifndef RANGES_V3_ALGORITHM_FILL_N_HPP 14 | #define RANGES_V3_ALGORITHM_FILL_N_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | namespace ranges 26 | { 27 | inline namespace v3 28 | { 29 | /// \addtogroup group-algorithms 30 | /// @{ 31 | struct fill_n_fn 32 | { 33 | template::value)> 36 | #else 37 | CONCEPT_REQUIRES_(WeakOutputIterator())> 38 | #endif 39 | O operator()(O begin, iterator_difference_t n, V const & val) const 40 | { 41 | RANGES_ASSERT(n >= 0); 42 | auto norig = n; 43 | auto b = uncounted(begin); 44 | for(; n != 0; ++b, --n) 45 | *b = val; 46 | return recounted(begin, b, norig); 47 | } 48 | }; 49 | 50 | /// \sa `fill_n_fn` 51 | /// \ingroup group-algorithms 52 | namespace 53 | { 54 | constexpr auto&& fill_n = static_const::value; 55 | } 56 | 57 | /// @} 58 | } // namespace v3 59 | } // namespace ranges 60 | 61 | #endif // include guard 62 | -------------------------------------------------------------------------------- /include/range/v3/view/filter.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_VIEW_FILTER_HPP 15 | #define RANGES_V3_VIEW_FILTER_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace ranges 23 | { 24 | inline namespace v3 25 | { 26 | namespace view 27 | { 28 | struct filter_fn 29 | { 30 | template 31 | remove_if_view, logical_negate> 32 | operator()(Rng && rng, Pred pred) const 33 | { 34 | CONCEPT_ASSERT(Range()); 35 | CONCEPT_ASSERT(IndirectCallablePredicate>()); 36 | return {all(std::forward(rng)), not_(std::move(pred))}; 37 | } 38 | template 39 | auto operator()(Pred pred) const -> 40 | decltype(make_pipeable(std::bind(*this, std::placeholders::_1, 41 | protect(std::move(pred))))) 42 | { 43 | return make_pipeable(std::bind(*this, std::placeholders::_1, 44 | protect(std::move(pred)))); 45 | } 46 | }; 47 | 48 | /// \relates filter_fn 49 | /// \ingroup group-views 50 | namespace 51 | { 52 | constexpr auto&& filter = static_const::value; 53 | } 54 | } 55 | } 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /test/view/drop_while.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | // Project home: https://github.com/ericniebler/range-v3 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "../simple_test.hpp" 18 | #include "../test_utils.hpp" 19 | 20 | int main() 21 | { 22 | using namespace ranges; 23 | auto rng0 = view::iota(10) | view::drop_while([](int i) { return i < 25; }); 24 | static_assert(range_cardinality::value == unknown, ""); 25 | ::models(rng0); 26 | ::models_not(rng0); 27 | ::models(rng0.begin()); 28 | auto b = rng0.begin(); 29 | CHECK(*b == 25); 30 | CHECK(*(b+1) == 26); 31 | ::check_equal(rng0 | view::take(10), {25, 26, 27, 28, 29, 30, 31, 32, 33, 34}); 32 | 33 | std::list vi{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 34 | auto rng1 = vi | view::drop_while([](int i) { return i != 50; }); 35 | static_assert(range_cardinality::value == ranges::finite, ""); 36 | ::models(rng1); 37 | ::models(rng1); 38 | ::models(rng1.begin()); 39 | CHECK(rng1.begin() == rng1.end()); 40 | 41 | // Check with a mutable predicate 42 | int rgi[] = {0,1,2,3,4,5,6,7,8,9}; 43 | int cnt = 0; 44 | auto mutable_only = view::drop_while(rgi, [cnt](int) mutable { return ++cnt <= 5;}); 45 | ::check_equal(mutable_only, {5,6,7,8,9}); 46 | CONCEPT_ASSERT(View()); 47 | CONCEPT_ASSERT(!View()); 48 | 49 | return test_result(); 50 | } 51 | -------------------------------------------------------------------------------- /include/range/v3/view/unbounded.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright Eric Niebler 2014 3 | // 4 | // Use, modification and distribution is subject to the 5 | // Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at 7 | // http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // Project home: https://github.com/ericniebler/range-v3 10 | // 11 | 12 | #ifndef RANGES_V3_VIEW_UNBOUNDED_HPP 13 | #define RANGES_V3_VIEW_UNBOUNDED_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace ranges 21 | { 22 | inline namespace v3 23 | { 24 | /// \addtogroup group-views 25 | /// @{ 26 | template 27 | struct unbounded_view 28 | : view_interface, infinite> 29 | { 30 | private: 31 | I it_; 32 | public: 33 | constexpr explicit unbounded_view(I it) 34 | : it_(detail::move(it)) 35 | {} 36 | constexpr I begin() const 37 | { 38 | return it_; 39 | } 40 | constexpr unreachable end() const 41 | { 42 | return {}; 43 | } 44 | }; 45 | 46 | namespace view 47 | { 48 | struct unbounded_fn 49 | { 50 | template 51 | constexpr unbounded_view operator()(I it) const 52 | { 53 | CONCEPT_ASSERT(InputIterator()); 54 | return unbounded_view{detail::move(it)}; 55 | } 56 | }; 57 | 58 | /// \relates unbounded_fn 59 | /// \ingroup group-views 60 | namespace 61 | { 62 | constexpr auto&& unbounded = static_const::value; 63 | } 64 | } 65 | /// @} 66 | } 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /test/action/split.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "../simple_test.hpp" 17 | #include "../test_utils.hpp" 18 | 19 | int main() 20 | { 21 | using namespace ranges; 22 | 23 | std::vector v = view::ints(1,21); 24 | std::vector> rgv = action::split(v, 10); 25 | CHECK(rgv.size() == 2u); 26 | ::check_equal(rgv[0], {1,2,3,4,5,6,7,8,9}); 27 | ::check_equal(rgv[1], {11,12,13,14,15,16,17,18,19,20}); 28 | 29 | using I = std::vector::iterator; 30 | std::vector> rgv2 = action::split(v, [](I b, I e){return std::make_pair(0 == (*b)%2,1);}); 31 | CHECK(rgv2.size() == 10u); 32 | ::check_equal(rgv2[0], {1}); 33 | ::check_equal(rgv2[1], {3}); 34 | ::check_equal(rgv2[2], {5}); 35 | ::check_equal(rgv2[3], {7}); 36 | ::check_equal(rgv2[4], {9}); 37 | ::check_equal(rgv2[5], {11}); 38 | ::check_equal(rgv2[6], {13}); 39 | ::check_equal(rgv2[7], {15}); 40 | ::check_equal(rgv2[8], {17}); 41 | ::check_equal(rgv2[9], {19}); 42 | 43 | std::string s{"This is his face"}; 44 | std::vector rgs = action::split(s, view::c_str(" ")); 45 | CHECK(rgs.size() == 4u); 46 | CHECK(rgs[0] == "This"); 47 | CHECK(rgs[1] == "is"); 48 | CHECK(rgs[2] == "his"); 49 | CHECK(rgs[3] == "face"); 50 | 51 | auto rgi = view::ints(1,21); 52 | std::vector> rgv3 = action::split(rgi, 10); 53 | CHECK(rgv3.size() == 2u); 54 | ::check_equal(rgv3[0], {1,2,3,4,5,6,7,8,9}); 55 | ::check_equal(rgv3[1], {11,12,13,14,15,16,17,18,19,20}); 56 | 57 | return ::test_result(); 58 | } 59 | -------------------------------------------------------------------------------- /include/range/v3/numeric/iota.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | #ifndef RANGES_V3_NUMERIC_IOTA_HPP 14 | #define RANGES_V3_NUMERIC_IOTA_HPP 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace ranges 23 | { 24 | inline namespace v3 25 | { 26 | struct iota_fn 27 | { 28 | template::value && IteratorRange::value && WeaklyIncrementable::value)> 31 | #else 32 | CONCEPT_REQUIRES_(OutputIterator() && IteratorRange() && WeaklyIncrementable())> 33 | #endif 34 | O operator()(O begin, S end, T val) const 35 | { 36 | for(; begin != end; ++begin, ++val) 37 | *begin = val; 38 | return begin; 39 | } 40 | 41 | template, 42 | #ifdef RANGES_WORKAROUND_MSVC_SFINAE_CONSTEXPR 43 | CONCEPT_REQUIRES_(OutputRange::value && WeaklyIncrementable::value)> 44 | #else 45 | CONCEPT_REQUIRES_(OutputRange() && WeaklyIncrementable())> 46 | #endif 47 | O operator()(Rng &rng, T val) const 48 | { 49 | return (*this)(begin(rng), end(rng), std::move(val)); 50 | } 51 | }; 52 | 53 | namespace 54 | { 55 | constexpr auto&& iota = static_const::value; 56 | } 57 | } 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/range/v3/utility/copy.hpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | // Range v3 library 3 | // 4 | // Copyright Eric Niebler 2013-2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | 14 | #ifndef RANGES_V3_UTILITY_COPY_HPP 15 | #define RANGES_V3_UTILITY_COPY_HPP 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace ranges 22 | { 23 | inline namespace v3 24 | { 25 | /// \addtogroup group-utility 26 | /// @{ 27 | namespace aux 28 | { 29 | struct copy_fn : copy_tag 30 | { 31 | template, T &&>::value)> 34 | #else 35 | CONCEPT_REQUIRES_(Constructible, T &&>())> 36 | #endif 37 | detail::decay_t operator()(T && t) const 38 | { 39 | return static_cast(t); 40 | } 41 | }; 42 | 43 | /// \ingroup group-utility 44 | /// \sa `copy_fn` 45 | namespace 46 | { 47 | constexpr auto&& copy = static_const::value; 48 | } 49 | 50 | /// \ingroup group-utility 51 | /// \sa `copy_fn` 52 | template, T &&>::value)> 55 | #else 56 | CONCEPT_REQUIRES_(Constructible, T &&>())> 57 | #endif 58 | detail::decay_t operator|(T && t, copy_fn) 59 | { 60 | return static_cast(t); 61 | } 62 | } 63 | /// @} 64 | } 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /test/action/sort.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // 5 | // Use, modification and distribution is subject to the 6 | // Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at 8 | // http://www.boost.org/LICENSE_1_0.txt) 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "../simple_test.hpp" 25 | #include "../test_utils.hpp" 26 | 27 | int main() 28 | { 29 | using namespace ranges; 30 | std::mt19937 gen; 31 | 32 | std::vector v = view::ints(0,100); 33 | v |= action::shuffle(gen); 34 | CHECK(!is_sorted(v)); 35 | 36 | auto v2 = v | copy | action::sort; 37 | CHECK(size(v2) == size(v)); 38 | CHECK(is_sorted(v2)); 39 | CHECK(!is_sorted(v)); 40 | ::models(v, v2); 41 | 42 | v |= action::sort; 43 | CHECK(is_sorted(v)); 44 | 45 | v |= action::shuffle(gen); 46 | CHECK(!is_sorted(v)); 47 | 48 | v = v | move | action::sort(std::less()); 49 | CHECK(is_sorted(v)); 50 | CHECK(equal(v, v2)); 51 | 52 | // Container algorithms can also be called directly 53 | // in which case they take and return by reference 54 | shuffle(v, gen); 55 | CHECK(!is_sorted(v)); 56 | auto & v3 = action::sort(v); 57 | CHECK(is_sorted(v)); 58 | CHECK(&v3 == &v); 59 | 60 | auto ref=std::ref(v); 61 | ref |= action::sort; 62 | 63 | // Can pipe a view to a "container" algorithm. 64 | action::sort(v, std::greater()); 65 | v | view::stride(2) | action::sort; 66 | check_equal(view::take(v, 10), {1,98,3,96,5,94,7,92,9,90}); 67 | 68 | return ::test_result(); 69 | } 70 | -------------------------------------------------------------------------------- /test/numeric/iota.cpp: -------------------------------------------------------------------------------- 1 | // Range v3 library 2 | // 3 | // Copyright Eric Niebler 2014 4 | // Copyright Gonzalo Brito Gadeschi 2014 5 | // 6 | // Use, modification and distribution is subject to the 7 | // Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // Project home: https://github.com/ericniebler/range-v3 12 | // 13 | // Implementation based on the code in libc++ 14 | // http://http://libcxx.llvm.org/ 15 | 16 | //===----------------------------------------------------------------------===// 17 | // 18 | // The LLVM Compiler Infrastructure 19 | // 20 | // This file is dual licensed under the MIT and the University of Illinois Open 21 | // Source Licenses. See LICENSE.TXT for details. 22 | // 23 | //===----------------------------------------------------------------------===// 24 | 25 | #include 26 | #include 27 | #include 28 | #include "../simple_test.hpp" 29 | #include "../test_iterators.hpp" 30 | 31 | template 32 | void test() 33 | { 34 | int ir[] = {5, 6, 7, 8, 9}; 35 | constexpr unsigned s = ranges::size(ir); 36 | { 37 | int ia[] = {1, 2, 3, 4, 5}; 38 | ranges::iota(Iter(ia), Sent(ia + s), 5); 39 | CHECK(ranges::equal(ia, ir)); 40 | } 41 | 42 | { 43 | int ia[] = {1, 2, 3, 4, 5}; 44 | auto rng = ranges::make_range(Iter(ia), Sent(ia + s)); 45 | ranges::iota(rng, 5); 46 | CHECK(ranges::equal(ia, ir)); 47 | } 48 | } 49 | 50 | int main() 51 | { 52 | test >(); 53 | test >(); 54 | test >(); 55 | test >(); 56 | test(); 57 | 58 | test, sentinel >(); 59 | test, sentinel >(); 60 | test, sentinel >(); 61 | test, sentinel >(); 62 | 63 | return ::test_result(); 64 | } 65 | -------------------------------------------------------------------------------- /include/meta/meta_fwd.hpp: -------------------------------------------------------------------------------- 1 | /// \file meta_fwd.hpp Forward declarations 2 | // 3 | // Meta library 4 | // 5 | // Copyright Eric Niebler 2014-2015 6 | // 7 | // Use, modification and distribution is subject to the 8 | // Boost Software License, Version 1.0. (See accompanying 9 | // file LICENSE_1_0.txt or copy at 10 | // http://www.boost.org/LICENSE_1_0.txt) 11 | // 12 | // Project home: https://github.com/ericniebler/meta 13 | // 14 | 15 | #ifndef META_FWD_HPP 16 | #define META_FWD_HPP 17 | 18 | #include 19 | 20 | #ifndef META_DISABLE_DEPRECATED_WARNINGS 21 | #ifdef __cpp_attribute_deprecated 22 | #define META_DEPRECATED(MSG) [[deprecated(MSG)]] 23 | #else 24 | #if defined(__clang__) || defined(__GNUC__) 25 | #define META_DEPRECATED(MSG) __attribute__((deprecated(MSG))) 26 | #elif defined(_MSC_VER) 27 | #define META_DEPRECATED(MSG) __declspec(deprecated(MSG)) 28 | #else 29 | #define META_DEPRECATED(MSG) 30 | #endif 31 | #endif 32 | #else 33 | #define META_DEPRECATED(MSG) 34 | #endif 35 | 36 | namespace meta 37 | { 38 | inline namespace v1 39 | { 40 | #if defined(__cpp_lib_integer_sequence) || (defined(_MSC_VER) && _MSC_VER >= 1900) 41 | using std::integer_sequence; 42 | #else 43 | template 44 | struct integer_sequence; 45 | #endif 46 | 47 | template 48 | struct list; 49 | 50 | template 51 | struct id; 52 | 53 | template