init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
155
Telegram/ThirdParty/range-v3/example/BUCK
vendored
Normal file
155
Telegram/ThirdParty/range-v3/example/BUCK
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
cxx_binary(
|
||||
name = 'comprehensions',
|
||||
srcs = [
|
||||
'comprehensions.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'count_if',
|
||||
srcs = [
|
||||
'count_if.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'count',
|
||||
srcs = [
|
||||
'count.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'find',
|
||||
srcs = [
|
||||
'find.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'for_each_assoc',
|
||||
srcs = [
|
||||
'for_each_assoc.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'for_each_sequence',
|
||||
srcs = [
|
||||
'for_each_sequence.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'hello',
|
||||
srcs = [
|
||||
'hello.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'is_sorted',
|
||||
srcs = [
|
||||
'is_sorted.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'filter_transform',
|
||||
srcs = [
|
||||
'filter_transform.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'accumulate_ints',
|
||||
srcs = [
|
||||
'accumulate_ints.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'comprehension_conversion',
|
||||
srcs = [
|
||||
'comprehension_conversion.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
|
||||
cxx_binary(
|
||||
name = 'sort_unique',
|
||||
srcs = [
|
||||
'sort_unique.cpp',
|
||||
],
|
||||
deps = [
|
||||
'//:range-v3',
|
||||
],
|
||||
compiler_flags = [
|
||||
'-std=c++14',
|
||||
],
|
||||
)
|
||||
39
Telegram/ThirdParty/range-v3/example/CMakeLists.txt
vendored
Normal file
39
Telegram/ThirdParty/range-v3/example/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
set(CMAKE_FOLDER "example")
|
||||
|
||||
add_subdirectory(view)
|
||||
|
||||
# examples use a less draconian set of compiler warnings
|
||||
ranges_append_flag(RANGES_HAS_WNO_MISSING_BRACES -Wno-missing-braces)
|
||||
ranges_append_flag(RANGES_HAS_WNO_SHORTEN_64_TO_32 -Wno-shorten-64-to-32)
|
||||
ranges_append_flag(RANGES_HAS_WNO_GLOBAL_CONSTRUCTORS -Wno-global-constructors)
|
||||
|
||||
rv3_add_test(example.comprehensions comprehensions comprehensions.cpp)
|
||||
rv3_add_test(example.hello hello hello.cpp)
|
||||
rv3_add_test(example.count count count.cpp)
|
||||
rv3_add_test(example.count_if count_if count_if.cpp)
|
||||
rv3_add_test(example.any_all_none_of any_all_none_of any_all_none_of.cpp)
|
||||
rv3_add_test(example.for_each_sequence for_each_sequence for_each_sequence.cpp)
|
||||
rv3_add_test(example.for_each_assoc for_each_assoc for_each_assoc.cpp)
|
||||
rv3_add_test(example.is_sorted is_sorted is_sorted.cpp)
|
||||
rv3_add_test(example.find find find.cpp)
|
||||
rv3_add_test(example.filter_transform filter_transform filter_transform.cpp)
|
||||
rv3_add_test(example.accumulate_ints accumulate_ints accumulate_ints.cpp)
|
||||
rv3_add_test(example.comprehension_conversion comprehension_conversion comprehension_conversion.cpp)
|
||||
rv3_add_test(example.sort_unique sort_unique sort_unique.cpp)
|
||||
|
||||
# Guarded with a variable because the calendar example causes gcc to puke.
|
||||
if(RANGES_BUILD_CALENDAR_EXAMPLE)
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_MULTITHREADED OFF)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
find_package(Boost 1.59.0 COMPONENTS date_time program_options)
|
||||
|
||||
if (Boost_FOUND)
|
||||
add_executable(range.v3.calendar calendar.cpp)
|
||||
target_include_directories(range.v3.calendar SYSTEM PRIVATE ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(range.v3.calendar PRIVATE range-v3 Boost::date_time Boost::program_options)
|
||||
message(STATUS "boost: ${Boost_LIBRARY_DIRS}")
|
||||
target_compile_definitions(range.v3.calendar PRIVATE BOOST_NO_AUTO_PTR)
|
||||
target_compile_options(range.v3.calendar PRIVATE -std=gnu++14)
|
||||
endif()
|
||||
endif()
|
||||
37
Telegram/ThirdParty/range-v3/example/accumulate_ints.cpp
vendored
Normal file
37
Telegram/ThirdParty/range-v3/example/accumulate_ints.cpp
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2019
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[accumulate_ints]
|
||||
// Sums the first ten squares and prints them, using views::ints to generate
|
||||
// and infinite range of integers, views::transform to square them, views::take
|
||||
// to drop all but the first 10, and accumulate to sum them.
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <range/v3/numeric/accumulate.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/take.hpp>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
using std::cout;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
int sum = accumulate(views::ints(1, unreachable) | views::transform([](int i) {
|
||||
return i * i;
|
||||
}) | views::take(10),
|
||||
0);
|
||||
// prints: 385
|
||||
cout << sum << '\n';
|
||||
}
|
||||
///[accumulate_ints]
|
||||
44
Telegram/ThirdParty/range-v3/example/any_all_none_of.cpp
vendored
Normal file
44
Telegram/ThirdParty/range-v3/example/any_all_none_of.cpp
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Jeff Garland 2017
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
//[any_all_none_of]]
|
||||
// Demonstrates any_of, all_of, none_of
|
||||
// output
|
||||
// vector: [6,2,3,4,5,6]
|
||||
// vector any_of is_six: true
|
||||
// vector all_of is_six: false
|
||||
// vector none_of is_six: false
|
||||
|
||||
#include <range/v3/algorithm/all_of.hpp>
|
||||
#include <range/v3/algorithm/any_of.hpp>
|
||||
#include <range/v3/algorithm/for_each.hpp>
|
||||
#include <range/v3/algorithm/none_of.hpp>
|
||||
#include <range/v3/view/all.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using std::cout;
|
||||
|
||||
auto is_six = [](int i) { return i == 6; };
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::vector<int> v{6, 2, 3, 4, 5, 6};
|
||||
cout << std::boolalpha;
|
||||
cout << "vector: " << ranges::views::all(v) << '\n';
|
||||
|
||||
cout << "vector any_of is_six: " << ranges::any_of(v, is_six) << '\n';
|
||||
cout << "vector all_of is_six: " << ranges::all_of(v, is_six) << '\n';
|
||||
cout << "vector none_of is_six: " << ranges::none_of(v, is_six) << '\n';
|
||||
}
|
||||
//[any_all_none_of]]
|
||||
373
Telegram/ThirdParty/range-v3/example/calendar.cpp
vendored
Normal file
373
Telegram/ThirdParty/range-v3/example/calendar.cpp
vendored
Normal file
@@ -0,0 +1,373 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2013-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
#include <range/v3/detail/config.hpp>
|
||||
|
||||
#if RANGES_CXX_RETURN_TYPE_DEDUCTION >= RANGES_CXX_RETURN_TYPE_DEDUCTION_14 && \
|
||||
RANGES_CXX_GENERIC_LAMBDAS >= RANGES_CXX_GENERIC_LAMBDAS_14
|
||||
|
||||
///[calendar]
|
||||
|
||||
// Usage:
|
||||
// calendar 2015
|
||||
//
|
||||
// Output:
|
||||
/*
|
||||
January February March
|
||||
1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7
|
||||
4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 14
|
||||
11 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21
|
||||
18 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28
|
||||
25 26 27 28 29 30 31 29 30 31
|
||||
|
||||
April May June
|
||||
1 2 3 4 1 2 1 2 3 4 5 6
|
||||
5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13
|
||||
12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20
|
||||
19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27
|
||||
26 27 28 29 30 24 25 26 27 28 29 30 28 29 30
|
||||
31
|
||||
July August September
|
||||
1 2 3 4 1 1 2 3 4 5
|
||||
5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12
|
||||
12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19
|
||||
19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26
|
||||
26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30
|
||||
30 31
|
||||
October November December
|
||||
1 2 3 1 2 3 4 5 6 7 1 2 3 4 5
|
||||
4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12
|
||||
11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19
|
||||
18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26
|
||||
25 26 27 28 29 30 31 29 30 27 28 29 30 31
|
||||
// */
|
||||
|
||||
// Credits:
|
||||
// Thanks to H. S. Teoh for the article that served as the
|
||||
// inspiration for this example:
|
||||
// <http://wiki.dlang.org/Component_programming_with_ranges>
|
||||
// Thanks to github's Arzar for bringing date::week_number
|
||||
// to my attention.
|
||||
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <range/v3/action/join.hpp>
|
||||
#include <range/v3/algorithm/copy.hpp>
|
||||
#include <range/v3/algorithm/for_each.hpp>
|
||||
#include <range/v3/algorithm/mismatch.hpp>
|
||||
#include <range/v3/core.hpp>
|
||||
#include <range/v3/iterator/stream_iterators.hpp>
|
||||
#include <range/v3/view/all.hpp>
|
||||
#include <range/v3/view/chunk.hpp>
|
||||
#include <range/v3/view/chunk_by.hpp>
|
||||
#include <range/v3/view/concat.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/join.hpp>
|
||||
#include <range/v3/view/repeat_n.hpp>
|
||||
#include <range/v3/view/single.hpp>
|
||||
#include <range/v3/view/take.hpp>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace po = boost::program_options;
|
||||
namespace greg = boost::gregorian;
|
||||
using date = greg::date;
|
||||
using day = greg::date_duration;
|
||||
using namespace ranges;
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace gregorian
|
||||
{
|
||||
date &operator++(date &d)
|
||||
{
|
||||
return d = d + day(1);
|
||||
}
|
||||
date operator++(date &d, int)
|
||||
{
|
||||
return ++d - day(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace ranges
|
||||
{
|
||||
template<>
|
||||
struct incrementable_traits<date>
|
||||
{
|
||||
using difference_type = date::duration_type::duration_rep::int_type;
|
||||
};
|
||||
}
|
||||
CPP_assert(incrementable<date>);
|
||||
|
||||
auto
|
||||
dates(unsigned short start, unsigned short stop)
|
||||
{
|
||||
return views::iota(date{start, greg::Jan, 1}, date{stop, greg::Jan, 1});
|
||||
}
|
||||
|
||||
auto
|
||||
dates_from(unsigned short year)
|
||||
{
|
||||
return views::iota(date{year, greg::Jan, 1});
|
||||
}
|
||||
|
||||
auto
|
||||
by_month()
|
||||
{
|
||||
return views::chunk_by(
|
||||
[](date a, date b) { return a.month() == b.month(); });
|
||||
}
|
||||
|
||||
auto
|
||||
by_week()
|
||||
{
|
||||
return views::chunk_by([](date a, date b) {
|
||||
// ++a because week_number is Mon-Sun and we want Sun-Sat
|
||||
return (++a).week_number() == (++b).week_number();
|
||||
});
|
||||
}
|
||||
|
||||
std::string
|
||||
format_day(date d)
|
||||
{
|
||||
return boost::str(boost::format("%|3|") % d.day());
|
||||
}
|
||||
|
||||
// In: range<range<date>>: month grouped by weeks.
|
||||
// Out: range<std::string>: month with formatted weeks.
|
||||
auto
|
||||
format_weeks()
|
||||
{
|
||||
return views::transform([](/*range<date>*/ auto week) {
|
||||
return boost::str(boost::format("%1%%2%%|22t|") %
|
||||
std::string(front(week).day_of_week() * 3u, ' ') %
|
||||
(week | views::transform(format_day) | actions::join));
|
||||
});
|
||||
}
|
||||
|
||||
// Return a formatted string with the title of the month
|
||||
// corresponding to a date.
|
||||
std::string
|
||||
month_title(date d)
|
||||
{
|
||||
return boost::str(boost::format("%|=22|") % d.month().as_long_string());
|
||||
}
|
||||
|
||||
// In: range<range<date>>: year of months of days
|
||||
// Out: range<range<std::string>>: year of months of formatted wks
|
||||
auto
|
||||
layout_months()
|
||||
{
|
||||
return views::transform([](/*range<date>*/ auto month) {
|
||||
auto week_count =
|
||||
static_cast<std::ptrdiff_t>(distance(month | by_week()));
|
||||
return views::concat(
|
||||
views::single(month_title(front(month))),
|
||||
month | by_week() | format_weeks(),
|
||||
views::repeat_n(std::string(22, ' '), 6 - week_count));
|
||||
});
|
||||
}
|
||||
|
||||
// Flattens a range of ranges by iterating the inner
|
||||
// ranges in round-robin fashion.
|
||||
template<class Rngs>
|
||||
class interleave_view : public view_facade<interleave_view<Rngs>>
|
||||
{
|
||||
friend range_access;
|
||||
std::vector<range_value_t<Rngs>> rngs_;
|
||||
struct cursor;
|
||||
cursor begin_cursor()
|
||||
{
|
||||
return {0, &rngs_, views::transform(rngs_, ranges::begin) | to<std::vector>};
|
||||
}
|
||||
|
||||
public:
|
||||
interleave_view() = default;
|
||||
explicit interleave_view(Rngs rngs)
|
||||
: rngs_(std::move(rngs) | to<std::vector>)
|
||||
{}
|
||||
};
|
||||
|
||||
template<class Rngs>
|
||||
struct interleave_view<Rngs>::cursor
|
||||
{
|
||||
std::size_t n_;
|
||||
std::vector<range_value_t<Rngs>> *rngs_;
|
||||
std::vector<iterator_t<range_value_t<Rngs>>> its_;
|
||||
decltype(auto) read() const
|
||||
{
|
||||
return *its_[n_];
|
||||
}
|
||||
void next()
|
||||
{
|
||||
if(0 == ((++n_) %= its_.size()))
|
||||
for_each(its_, [](auto &it) { ++it; });
|
||||
}
|
||||
bool equal(default_sentinel_t) const
|
||||
{
|
||||
if(n_ != 0)
|
||||
return false;
|
||||
auto ends = *rngs_ | views::transform(ranges::end);
|
||||
return its_.end() != std::mismatch(
|
||||
its_.begin(), its_.end(), ends.begin(), std::not_equal_to<>{}).first;
|
||||
}
|
||||
CPP_member
|
||||
auto equal(cursor const& that) const -> CPP_ret(bool)(
|
||||
requires forward_range<range_value_t<Rngs>>)
|
||||
{
|
||||
return n_ == that.n_ && its_ == that.its_;
|
||||
}
|
||||
};
|
||||
|
||||
// In: range<range<T>>
|
||||
// Out: range<T>, flattened by walking the ranges
|
||||
// round-robin fashion.
|
||||
auto
|
||||
interleave()
|
||||
{
|
||||
return make_view_closure([](auto &&rngs) {
|
||||
using Rngs = decltype(rngs);
|
||||
return interleave_view<views::all_t<Rngs>>(
|
||||
views::all(std::forward<Rngs>(rngs)));
|
||||
});
|
||||
}
|
||||
|
||||
// In: range<range<T>>
|
||||
// Out: range<range<T>>, transposing the rows and columns.
|
||||
auto
|
||||
transpose()
|
||||
{
|
||||
return make_view_closure([](auto &&rngs) {
|
||||
using Rngs = decltype(rngs);
|
||||
CPP_assert(forward_range<Rngs>);
|
||||
return std::forward<Rngs>(rngs)
|
||||
| interleave()
|
||||
| views::chunk(static_cast<std::size_t>(distance(rngs)));
|
||||
});
|
||||
}
|
||||
|
||||
// In: range<range<range<string>>>
|
||||
// Out: range<range<range<string>>>, transposing months.
|
||||
auto
|
||||
transpose_months()
|
||||
{
|
||||
return views::transform(
|
||||
[](/*range<range<string>>*/ auto rng) { return rng | transpose(); });
|
||||
}
|
||||
|
||||
// In: range<range<string>>
|
||||
// Out: range<string>, joining the strings of the inner ranges
|
||||
auto
|
||||
join_months()
|
||||
{
|
||||
return views::transform(
|
||||
[](/*range<string>*/ auto rng) { return actions::join(rng); });
|
||||
}
|
||||
|
||||
// In: range<date>
|
||||
// Out: range<string>, lines of formatted output
|
||||
auto
|
||||
format_calendar(std::size_t months_per_line)
|
||||
{
|
||||
return
|
||||
// Group the dates by month:
|
||||
by_month()
|
||||
// Format the month into a range of strings:
|
||||
| layout_months()
|
||||
// Group the months that belong side-by-side:
|
||||
| views::chunk(months_per_line)
|
||||
// Transpose the rows and columns of the size-by-side months:
|
||||
| transpose_months()
|
||||
// Ungroup the side-by-side months:
|
||||
| views::join
|
||||
// Join the strings of the transposed months:
|
||||
| join_months();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) try
|
||||
{
|
||||
// Declare the supported options.
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()("help", "produce help message")(
|
||||
"start", po::value<unsigned short>(), "Year to start")(
|
||||
"stop", po::value<std::string>(), "Year to stop")(
|
||||
"per-line",
|
||||
po::value<std::size_t>()->default_value(3u),
|
||||
"Nbr of months per line");
|
||||
|
||||
po::positional_options_description p;
|
||||
p.add("start", 1).add("stop", 1);
|
||||
|
||||
po::variables_map vm;
|
||||
po::store(
|
||||
po::command_line_parser(argc, argv).options(desc).positional(p).run(),
|
||||
vm);
|
||||
po::notify(vm);
|
||||
|
||||
if(vm.count("help") || 1 != vm.count("start"))
|
||||
{
|
||||
std::cerr << desc << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto const start = vm["start"].as<unsigned short>();
|
||||
auto const stop = 0 == vm.count("stop")
|
||||
? (unsigned short)(start + 1)
|
||||
: vm["stop"].as<std::string>() == "never"
|
||||
? (unsigned short)-1
|
||||
: boost::lexical_cast<unsigned short>(
|
||||
vm["stop"].as<std::string>());
|
||||
auto const months_per_line = vm["per-line"].as<std::size_t>();
|
||||
|
||||
if(stop != (unsigned short)-1 && stop <= start)
|
||||
{
|
||||
std::cerr << "ERROR: The stop year must be larger than the start"
|
||||
<< '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((unsigned short)-1 != stop)
|
||||
{
|
||||
copy(dates(start, stop) | format_calendar(months_per_line),
|
||||
ostream_iterator<>(std::cout, "\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
copy(dates_from(start) | format_calendar(months_per_line),
|
||||
ostream_iterator<>(std::cout, "\n"));
|
||||
}
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cerr << "ERROR: Unhandled exception\n";
|
||||
std::cerr << " what(): " << e.what();
|
||||
return 1;
|
||||
}
|
||||
///[calendar]
|
||||
|
||||
#else
|
||||
#pragma message( \
|
||||
"calendar requires C++14 return type deduction and generic lambdas")
|
||||
int
|
||||
main()
|
||||
{}
|
||||
#endif
|
||||
35
Telegram/ThirdParty/range-v3/example/comprehension_conversion.cpp
vendored
Normal file
35
Telegram/ThirdParty/range-v3/example/comprehension_conversion.cpp
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2019
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[comprehension_conversion]
|
||||
// Use a range comprehension (views::for_each) to construct a custom range, and
|
||||
// then convert it to a std::vector.
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <range/v3/range/conversion.hpp>
|
||||
#include <range/v3/view/for_each.hpp>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
#include <range/v3/view/repeat_n.hpp>
|
||||
using std::cout;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace ranges;
|
||||
auto vi = views::for_each(views::ints(1, 6),
|
||||
[](int i) { return yield_from(views::repeat_n(i, i)); }) |
|
||||
to<std::vector>();
|
||||
// prints: [1,2,2,3,3,3,4,4,4,4,5,5,5,5,5]
|
||||
cout << views::all(vi) << '\n';
|
||||
}
|
||||
///[comprehension_conversion]
|
||||
124
Telegram/ThirdParty/range-v3/example/comprehensions.cpp
vendored
Normal file
124
Telegram/ThirdParty/range-v3/example/comprehensions.cpp
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2013-present
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <range/v3/all.hpp>
|
||||
|
||||
using namespace ranges;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
// Define an infinite range containing all the Pythagorean triples:
|
||||
auto triples = views::for_each(views::iota(1), [](int z) {
|
||||
return views::for_each(views::iota(1, z + 1), [=](int x) {
|
||||
return views::for_each(views::iota(x, z + 1), [=](int y) {
|
||||
return yield_if(x * x + y * y == z * z,
|
||||
std::make_tuple(x, y, z));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//// This alternate syntax also works:
|
||||
// auto triples = iota(1) >>= [] (int z) { return
|
||||
// iota(1, z+1) >>= [=](int x) { return
|
||||
// iota(x, z+1) >>= [=](int y) { return
|
||||
// yield_if(x*x + y*y == z*z,
|
||||
// std::make_tuple(x, y, z)); };}; };
|
||||
|
||||
// Display the first 100 triples
|
||||
RANGES_FOR(auto triple, triples | views::take(100))
|
||||
{
|
||||
std::cout << '(' << std::get<0>(triple) << ',' << std::get<1>(triple)
|
||||
<< ',' << std::get<2>(triple) << ')' << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Benchmark Code
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class timer
|
||||
{
|
||||
private:
|
||||
std::chrono::high_resolution_clock::time_point start_;
|
||||
|
||||
public:
|
||||
timer()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
void reset()
|
||||
{
|
||||
start_ = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
std::chrono::milliseconds elapsed() const
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::high_resolution_clock::now() - start_);
|
||||
}
|
||||
friend std::ostream &operator<<(std::ostream &sout, timer const &t)
|
||||
{
|
||||
return sout << t.elapsed().count() << "ms";
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
benchmark()
|
||||
{
|
||||
// Define an infinite range containing all the Pythagorean triples:
|
||||
auto triples = views::for_each(views::iota(1), [](int z) {
|
||||
return views::for_each(views::iota(1, z + 1), [=](int x) {
|
||||
return views::for_each(views::iota(x, z + 1), [=](int y) {
|
||||
return yield_if(x * x + y * y == z * z,
|
||||
std::make_tuple(x, y, z));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
static constexpr int max_triples = 3000;
|
||||
|
||||
timer t;
|
||||
int result = 0;
|
||||
RANGES_FOR(auto triple, triples | views::take(max_triples))
|
||||
{
|
||||
int i, j, k;
|
||||
std::tie(i, j, k) = triple;
|
||||
result += (i + j + k);
|
||||
}
|
||||
std::cout << t << '\n';
|
||||
std::cout << result << '\n';
|
||||
|
||||
result = 0;
|
||||
int found = 0;
|
||||
t.reset();
|
||||
for(int z = 1;; ++z)
|
||||
{
|
||||
for(int x = 1; x <= z; ++x)
|
||||
{
|
||||
for(int y = x; y <= z; ++y)
|
||||
{
|
||||
if(x * x + y * y == z * z)
|
||||
{
|
||||
result += (x + y + z);
|
||||
++found;
|
||||
if(found == max_triples)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
std::cout << t << '\n';
|
||||
std::cout << result << '\n';
|
||||
}
|
||||
40
Telegram/ThirdParty/range-v3/example/count.cpp
vendored
Normal file
40
Telegram/ThirdParty/range-v3/example/count.cpp
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Jeff Garland 2017
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[count]
|
||||
// This example demonstrates counting the number of
|
||||
// elements that match a given value.
|
||||
// output...
|
||||
// vector: 2
|
||||
// array: 2
|
||||
|
||||
#include <iostream>
|
||||
#include <range/v3/algorithm/count.hpp> // specific includes
|
||||
#include <vector>
|
||||
using std::cout;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::vector<int> v{6, 2, 3, 4, 5, 6};
|
||||
// note the count return is a numeric type
|
||||
// like int or long -- auto below make sure
|
||||
// it matches the implementation
|
||||
auto c = ranges::count(v, 6);
|
||||
cout << "vector: " << c << '\n';
|
||||
|
||||
std::array<int, 6> a{6, 2, 3, 4, 5, 6};
|
||||
c = ranges::count(a, 6);
|
||||
cout << "array: " << c << '\n';
|
||||
}
|
||||
|
||||
///[count]
|
||||
39
Telegram/ThirdParty/range-v3/example/count_if.cpp
vendored
Normal file
39
Telegram/ThirdParty/range-v3/example/count_if.cpp
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Jeff Garland 2017
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[count_if]
|
||||
// This example counts element of a range that match a supplied predicate.
|
||||
// output
|
||||
// vector: 2
|
||||
// array: 2
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <range/v3/algorithm/count_if.hpp> // specific includes
|
||||
#include <vector>
|
||||
using std::cout;
|
||||
|
||||
auto is_six = [](int i) -> bool { return i == 6; };
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::vector<int> v{6, 2, 3, 4, 5, 6};
|
||||
auto c = ranges::count_if(v, is_six);
|
||||
cout << "vector: " << c << '\n'; // 2
|
||||
|
||||
std::array<int, 6> a{6, 2, 3, 4, 5, 6};
|
||||
c = ranges::count_if(a, is_six);
|
||||
cout << "array: " << c << '\n'; // 2
|
||||
}
|
||||
///[count_if]
|
||||
34
Telegram/ThirdParty/range-v3/example/filter_transform.cpp
vendored
Normal file
34
Telegram/ThirdParty/range-v3/example/filter_transform.cpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2019
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[filter_transform]
|
||||
// This example demonstrates filtering and transforming a range on the
|
||||
// fly with view adaptors.
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <range/v3/view/filter.hpp>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
using std::cout;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int> const vi{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
using namespace ranges;
|
||||
auto rng = vi | views::filter([](int i) { return i % 2 == 0; }) |
|
||||
views::transform([](int i) { return std::to_string(i); });
|
||||
// prints: [2,4,6,8,10]
|
||||
cout << rng << '\n';
|
||||
}
|
||||
///[filter_transform]
|
||||
118
Telegram/ThirdParty/range-v3/example/find.cpp
vendored
Normal file
118
Telegram/ThirdParty/range-v3/example/find.cpp
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Jeff Garland 2017
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[find]
|
||||
// vector: *i: 6
|
||||
// didn't find 10
|
||||
// *i: 6
|
||||
// *i: 2
|
||||
// *i after ++ (2 expected): 2
|
||||
// array: *i: 6
|
||||
// list: *i: 6
|
||||
// fwd_list: *i: 4
|
||||
// deque: *i: 6
|
||||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <range/v3/all.hpp>
|
||||
#include <vector>
|
||||
using std::cout;
|
||||
|
||||
auto is_six = [](int i) -> bool { return i == 6; };
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
cout << "vector: ";
|
||||
|
||||
std::vector<int> v{6, 2, 6, 4, 6, 1};
|
||||
{
|
||||
auto i = ranges::find(v, 6); // 1 2 3 4 5 6
|
||||
cout << "*i: " << *i << '\n';
|
||||
}
|
||||
{
|
||||
auto i = ranges::find(v, 10); // 1 2 3 4 5 6
|
||||
if(i == ranges::end(v))
|
||||
{
|
||||
cout << "didn't find 10\n";
|
||||
}
|
||||
}
|
||||
{
|
||||
auto i = ranges::find_if(v, is_six);
|
||||
if(i != ranges::end(v))
|
||||
{
|
||||
cout << "*i: " << *i << '\n';
|
||||
}
|
||||
}
|
||||
{
|
||||
auto i = ranges::find_if_not(v, is_six);
|
||||
if(i != ranges::end(v))
|
||||
{
|
||||
cout << "*i: " << *i << '\n';
|
||||
}
|
||||
}
|
||||
{
|
||||
auto i = ranges::find(v, 6);
|
||||
i++;
|
||||
if(i != ranges::end(v))
|
||||
{
|
||||
cout << "*i after ++ (2 expected): " << *i;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "\narray: ";
|
||||
|
||||
std::array<int, 6> a{6, 2, 3, 4, 5, 1};
|
||||
{
|
||||
auto i = ranges::find(a, 6);
|
||||
if(i != ranges::end(a))
|
||||
{
|
||||
cout << "*i: " << *i;
|
||||
}
|
||||
}
|
||||
cout << "\nlist: ";
|
||||
|
||||
std::list<int> li{6, 2, 3, 4, 5, 1};
|
||||
{
|
||||
auto i = ranges::find(li, 6);
|
||||
if(i != ranges::end(li))
|
||||
{
|
||||
cout << "*i: " << *i;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "\nfwd_list: ";
|
||||
|
||||
std::forward_list<int> fl{6, 2, 3, 4, 5, 1};
|
||||
{
|
||||
auto i = ranges::find(fl, 4);
|
||||
if(i != ranges::end(fl))
|
||||
{
|
||||
cout << "*i: " << *i;
|
||||
}
|
||||
}
|
||||
cout << "\ndeque: ";
|
||||
|
||||
std::deque<int> d{6, 2, 3, 4, 5, 1};
|
||||
{
|
||||
auto i = ranges::find(d, 6);
|
||||
if(i != ranges::end(d))
|
||||
{
|
||||
cout << "*i: " << *i;
|
||||
}
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
///[find]
|
||||
58
Telegram/ThirdParty/range-v3/example/for_each_assoc.cpp
vendored
Normal file
58
Telegram/ThirdParty/range-v3/example/for_each_assoc.cpp
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Jeff Garland 2017
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[for_each_assoc]
|
||||
// for_each with associative containers
|
||||
// output
|
||||
// set: 1 2 3 4 5 6
|
||||
// map: one:1 three:3 two:2
|
||||
// unordered_map: three:3 one:1 two:2
|
||||
// unordered_set: 6 5 4 3 2 1
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <range/v3/algorithm/for_each.hpp>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
using std::cout;
|
||||
using std::string;
|
||||
|
||||
auto print = [](int i) { cout << i << ' '; };
|
||||
// must take a pair for map types
|
||||
auto printm = [](std::pair<string, int> p) {
|
||||
cout << p.first << ":" << p.second << ' ';
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
cout << "set: ";
|
||||
std::set<int> si{1, 2, 3, 4, 5, 6};
|
||||
ranges::for_each(si, print);
|
||||
|
||||
cout << "\nmap: ";
|
||||
std::map<string, int> msi{{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
ranges::for_each(msi, printm);
|
||||
|
||||
cout << "\nunordered map: ";
|
||||
std::unordered_map<string, int> umsi{{"one", 1}, {"two", 2}, {"three", 3}};
|
||||
ranges::for_each(umsi, printm);
|
||||
|
||||
cout << "\nunordered set: ";
|
||||
std::unordered_set<int> usi{1, 2, 3, 4, 5, 6};
|
||||
ranges::for_each(usi, print);
|
||||
cout << '\n';
|
||||
}
|
||||
///[for_each_assoc]
|
||||
59
Telegram/ThirdParty/range-v3/example/for_each_sequence.cpp
vendored
Normal file
59
Telegram/ThirdParty/range-v3/example/for_each_sequence.cpp
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Jeff Garland 2017
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[for_each_sequence]
|
||||
// Use the for_each to print from various containers
|
||||
// output
|
||||
// vector: 1 2 3 4 5 6
|
||||
// array: 1 2 3 4 5 6
|
||||
// list: 1 2 3 4 5 6
|
||||
// fwd_list: 1 2 3 4 5 6
|
||||
// deque: 1 2 3 4 5 6
|
||||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <queue>
|
||||
#include <range/v3/algorithm/for_each.hpp> // specific includes
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
using std::cout;
|
||||
|
||||
auto print = [](int i) { cout << i << ' '; };
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
cout << "vector: ";
|
||||
std::vector<int> v{1, 2, 3, 4, 5, 6};
|
||||
ranges::for_each(v, print); // 1 2 3 4 5 6
|
||||
|
||||
cout << "\narray: ";
|
||||
std::array<int, 6> a{1, 2, 3, 4, 5, 6};
|
||||
ranges::for_each(a, print);
|
||||
|
||||
cout << "\nlist: ";
|
||||
std::list<int> ll{1, 2, 3, 4, 5, 6};
|
||||
ranges::for_each(ll, print);
|
||||
|
||||
cout << "\nfwd_list: ";
|
||||
std::forward_list<int> fl{1, 2, 3, 4, 5, 6};
|
||||
ranges::for_each(fl, print);
|
||||
|
||||
cout << "\ndeque: ";
|
||||
std::deque<int> d{1, 2, 3, 4, 5, 6};
|
||||
ranges::for_each(d, print);
|
||||
cout << '\n';
|
||||
}
|
||||
///[for_each_sequence]
|
||||
29
Telegram/ThirdParty/range-v3/example/hello.cpp
vendored
Normal file
29
Telegram/ThirdParty/range-v3/example/hello.cpp
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Jeff Garland 2017
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[hello]
|
||||
#include <iostream>
|
||||
#include <range/v3/all.hpp> // get everything
|
||||
#include <string>
|
||||
using std::cout;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::string s{"hello"};
|
||||
|
||||
// output: h e l l o
|
||||
ranges::for_each(s, [](char c) { cout << c << ' '; });
|
||||
cout << '\n';
|
||||
}
|
||||
///[hello]
|
||||
35
Telegram/ThirdParty/range-v3/example/is_sorted.cpp
vendored
Normal file
35
Telegram/ThirdParty/range-v3/example/is_sorted.cpp
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Jeff Garland 2017
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[is_sorted]
|
||||
// Check if a container is sorted
|
||||
// output
|
||||
// vector: true
|
||||
// array: false
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <range/v3/algorithm/is_sorted.hpp> // specific includes
|
||||
#include <vector>
|
||||
using std::cout;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
cout << std::boolalpha;
|
||||
std::vector<int> v{1, 2, 3, 4, 5, 6};
|
||||
cout << "vector: " << ranges::is_sorted(v) << '\n';
|
||||
|
||||
std::array<int, 6> a{6, 2, 3, 4, 5, 6};
|
||||
cout << "array: " << ranges::is_sorted(a) << '\n';
|
||||
}
|
||||
///[is_sorted]
|
||||
34
Telegram/ThirdParty/range-v3/example/sort_unique.cpp
vendored
Normal file
34
Telegram/ThirdParty/range-v3/example/sort_unique.cpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Range v3 library
|
||||
//
|
||||
// Copyright Eric Niebler 2019
|
||||
//
|
||||
// Use, modification and distribution is subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Project home: https://github.com/ericniebler/range-v3
|
||||
//
|
||||
|
||||
///[sort_unique]
|
||||
// Remove all non-unique elements from a container.
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <range/v3/action/sort.hpp>
|
||||
#include <range/v3/action/unique.hpp>
|
||||
#include <range/v3/view/all.hpp>
|
||||
using std::cout;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int> vi{9, 4, 5, 2, 9, 1, 0, 2, 6, 7, 4, 5, 6, 5, 9, 2, 7,
|
||||
1, 4, 5, 3, 8, 5, 0, 2, 9, 3, 7, 5, 7, 5, 5, 6, 1,
|
||||
4, 3, 1, 8, 4, 0, 7, 8, 8, 2, 6, 5, 3, 4, 5};
|
||||
using namespace ranges;
|
||||
vi |= actions::sort | actions::unique;
|
||||
// prints: [0,1,2,3,4,5,6,7,8,9]
|
||||
cout << views::all(vi) << '\n';
|
||||
}
|
||||
///[sort_unique]
|
||||
11
Telegram/ThirdParty/range-v3/example/view/CMakeLists.txt
vendored
Normal file
11
Telegram/ThirdParty/range-v3/example/view/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
set(CMAKE_FOLDER "${CMAKE_FOLDER}/view")
|
||||
|
||||
rv3_add_test(example.view.transform example.view.transform transform.cpp)
|
||||
rv3_add_test(example.view.ints example.view.ints ints.cpp)
|
||||
rv3_add_test(example.view.filter example.view.filter filter.cpp)
|
||||
|
||||
# NOTE: Make sure the output matches the contents of the corresponding golden file
|
||||
set_tests_properties(range.v3.example.view.transform PROPERTIES PASS_REGULAR_EXPRESSION "\\[0.5,1,1.5\\]")
|
||||
set_tests_properties(range.v3.example.view.ints PROPERTIES PASS_REGULAR_EXPRESSION "\\[3,4,5,6\\]")
|
||||
set_tests_properties(range.v3.example.view.filter PROPERTIES PASS_REGULAR_EXPRESSION "\\[2,4\\]")
|
||||
|
||||
18
Telegram/ThirdParty/range-v3/example/view/filter.cpp
vendored
Normal file
18
Telegram/ThirdParty/range-v3/example/view/filter.cpp
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//! [filter example]
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <range/v3/view/filter.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int> numbers{1, 2, 3, 4};
|
||||
|
||||
auto even = numbers
|
||||
// Keep only the even numbers
|
||||
| ranges::views::filter([](const int& num) {
|
||||
return num % 2 == 0;
|
||||
});
|
||||
|
||||
std::cout << even << '\n';
|
||||
}
|
||||
//! [filter example]
|
||||
1
Telegram/ThirdParty/range-v3/example/view/filter_golden.txt
vendored
Normal file
1
Telegram/ThirdParty/range-v3/example/view/filter_golden.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[2,4]
|
||||
12
Telegram/ThirdParty/range-v3/example/view/ints.cpp
vendored
Normal file
12
Telegram/ThirdParty/range-v3/example/view/ints.cpp
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
//! [ints example]
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <range/v3/view/iota.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
auto numbers = ranges::views::ints(3, 7);
|
||||
|
||||
std::cout << numbers << '\n';
|
||||
}
|
||||
//! [ints example]
|
||||
1
Telegram/ThirdParty/range-v3/example/view/ints_golden.txt
vendored
Normal file
1
Telegram/ThirdParty/range-v3/example/view/ints_golden.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[3,4,5,6]
|
||||
18
Telegram/ThirdParty/range-v3/example/view/transform.cpp
vendored
Normal file
18
Telegram/ThirdParty/range-v3/example/view/transform.cpp
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//! [transform example]
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int> numbers{1, 2, 3};
|
||||
|
||||
auto halved = numbers
|
||||
// Divide each integer by 2, converting it into a double
|
||||
| ranges::views::transform([](const int& num) {
|
||||
return num / 2.0;
|
||||
});
|
||||
|
||||
std::cout << halved << '\n';
|
||||
}
|
||||
//! [transform example]
|
||||
1
Telegram/ThirdParty/range-v3/example/view/transform_golden.txt
vendored
Normal file
1
Telegram/ThirdParty/range-v3/example/view/transform_golden.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
[0.5,1,1.5]
|
||||
Reference in New Issue
Block a user