Compare commits

..

No commits in common. "3deeedc7aa91242f0167a6b64dabe321b27bf628" and "b71ef30f3e8cb35238c27a1c055beceb88b7a19d" have entirely different histories.

2 changed files with 20 additions and 33 deletions

View File

@ -1,10 +0,0 @@
#include "../vmake.hpp"
#include <iostream>
using namespace std;
int main() {
vmake::outputln_n(cout, 1000, " ", vmake::filter(
vmake::rng::uniform_ints(vmake::require_unique, 1, 10000),
[](auto x) { return x % 2 == 0; }));
}

View File

@ -19,6 +19,24 @@ struct sequence_terminated_error : std::exception {
} }
}; };
namespace details {
template<typename T>
auto is_sequence_helper(char) -> decltype(
std::declval<T>()()
, std::declval<T>().is_terminated()
, typename std::enable_if<std::is_same<decltype(std::declval<T>()())
, typename T::result>::value, int>::type()
, std::true_type{});
template<typename T>
auto is_sequence_helper(int) -> std::false_type;
}
template<typename T>
using is_sequence_t = decltype(details::is_sequence_helper<T>(' '));
namespace polyfill { namespace polyfill {
#if __cplusplus >= 201703L #if __cplusplus >= 201703L
@ -57,26 +75,6 @@ decltype(auto) apply(Func &&f, Tuple &&t) {
namespace details { namespace details {
template<typename T>
auto is_sequence_helper(char) -> decltype(
std::declval<T>()()
, typename std::enable_if<std::is_same<decltype(
std::declval<typename polyfill::add_const_t<T>::type>().is_terminated())
, bool>::value, int>::type{0}
, typename std::enable_if<std::is_same<decltype(std::declval<T>()())
, typename T::result>::value, int>::type{0}
, std::true_type{});
template<typename T>
auto is_sequence_helper(int) -> std::false_type;
}
template<typename T>
using is_sequence_t = decltype(details::is_sequence_helper<T>(' '));
namespace details {
template<typename T> template<typename T>
struct iota_sequence { struct iota_sequence {
using result = T; using result = T;
@ -610,7 +608,7 @@ struct unique_ints_sequence {
} }
auto operator()() { auto operator()() {
if (!halfed && (used.size() + 1) * 2 - (r - l + 1) >= 0) { if (!halfed && Tval{(used.size() + 1) * 2} >= r - l + 1) {
for (Tval i = l; i <= r; ++i) { for (Tval i = l; i <= r; ++i) {
if (!used.count(i)) rest.push_back(i); if (!used.count(i)) rest.push_back(i);
} }
@ -743,7 +741,6 @@ namespace _checks {
using empty_sequence_int = decltype(nothing<int>()); using empty_sequence_int = decltype(nothing<int>());
/*
static_assert(is_sequence_t<empty_sequence_int>::value static_assert(is_sequence_t<empty_sequence_int>::value
&& is_sequence_t<decltype(take(empty_sequence_int{}, 1))>::value && is_sequence_t<decltype(take(empty_sequence_int{}, 1))>::value
&& is_sequence_t<decltype(group<20>(empty_sequence_int{}))>::value && is_sequence_t<decltype(group<20>(empty_sequence_int{}))>::value
@ -751,7 +748,7 @@ static_assert(is_sequence_t<empty_sequence_int>::value
&& !is_sequence_t<int>::value && !is_sequence_t<int>::value
&& !is_sequence_t<std::less<int>>::value && !is_sequence_t<std::less<int>>::value
, "compile-time self-checking failed(try upgrading your compiler)."); , "compile-time self-checking failed(try upgrading your compiler).");
*/
} // namespace _checks } // namespace _checks
} // namespace vmake } // namespace vmake