forked from lewissbaker/cppcoro
-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathsequence_traits.hpp
More file actions
33 lines (27 loc) · 904 Bytes
/
Copy pathsequence_traits.hpp
File metadata and controls
33 lines (27 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) Lewis Baker
// Licenced under MIT license. See LICENSE.txt for details.
///////////////////////////////////////////////////////////////////////////////
#ifndef CPPCORO_SEQUENCE_TRAITS_HPP_INCLUDED
#define CPPCORO_SEQUENCE_TRAITS_HPP_INCLUDED
#include <type_traits>
namespace cppcoro
{
template<typename SEQUENCE>
struct sequence_traits
{
using value_type = SEQUENCE;
using difference_type = std::make_signed_t<SEQUENCE>;
using size_type = std::make_unsigned_t<SEQUENCE>;
static constexpr value_type initial_sequence = static_cast<value_type>(-1);
static constexpr difference_type difference(value_type a, value_type b)
{
return static_cast<difference_type>(a - b);
}
static constexpr bool precedes(value_type a, value_type b)
{
return difference(a, b) < 0;
}
};
}
#endif