Go to the documentation of this file.
12 #ifndef NONSTD_RING_SPAN_LITE_HPP
13 #define NONSTD_RING_SPAN_LITE_HPP
15 #define ring_span_lite_MAJOR 0
16 #define ring_span_lite_MINOR 3
17 #define ring_span_lite_PATCH 0
19 #define ring_span_lite_VERSION \
20 nsrs_STRINGIFY(ring_span_lite_MAJOR) "." nsrs_STRINGIFY( \
21 ring_span_lite_MINOR) "." nsrs_STRINGIFY(ring_span_lite_PATCH)
23 #define nsrs_STRINGIFY(x) nsrs_STRINGIFY_(x)
24 #define nsrs_STRINGIFY_(x) #x
28 #define nsrs_RING_SPAN_DEFAULT 0
29 #define nsrs_RING_SPAN_NONSTD 1
30 #define nsrs_RING_SPAN_STD 2
32 #if !defined(nsrs_CONFIG_SELECT_RING_SPAN)
33 #define nsrs_CONFIG_SELECT_RING_SPAN \
34 (nsrs_HAVE_STD_RING_SPAN ? nsrs_RING_SPAN_STD : nsrs_RING_SPAN_NONSTD)
37 #ifndef nsrs_CONFIG_STRICT_P0059
38 #define nsrs_CONFIG_STRICT_P0059 0
41 #define nsrs_RING_SPAN_LITE_EXTENSION (!nsrs_CONFIG_STRICT_P0059)
43 #ifndef nsrs_CONFIG_CONFIRMS_COMPILATION_ERRORS
44 #define nsrs_CONFIG_CONFIRMS_COMPILATION_ERRORS 0
50 #ifndef nsrs_CPLUSPLUS
51 #if defined(_MSVC_LANG) && !defined(__clang__)
52 #define nsrs_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG)
54 #define nsrs_CPLUSPLUS __cplusplus
58 #define nsrs_CPP98_OR_GREATER (nsrs_CPLUSPLUS >= 199711L)
59 #define nsrs_CPP11_OR_GREATER (nsrs_CPLUSPLUS >= 201103L)
60 #define nsrs_CPP11_OR_GREATER_ (nsrs_CPLUSPLUS >= 201103L)
61 #define nsrs_CPP14_OR_GREATER (nsrs_CPLUSPLUS >= 201402L)
62 #define nsrs_CPP17_OR_GREATER (nsrs_CPLUSPLUS >= 201703L)
63 #define nsrs_CPP20_OR_GREATER (nsrs_CPLUSPLUS >= 202000L)
67 #define nsrs_HAVE_STD_RING_SPAN 0
79 #define nsrs_USES_STD_RING_SPAN \
80 ((nsrs_CONFIG_SELECT_RING_SPAN == nsrs_RING_SPAN_STD) || \
81 ((nsrs_CONFIG_SELECT_RING_SPAN == nsrs_RING_SPAN_DEFAULT) && \
82 nsrs_HAVE_STD_RING_SPAN))
102 #if defined(_MSC_VER) && !defined(__clang__)
103 #define nsrs_COMPILER_MSVC_VER (_MSC_VER)
104 #define nsrs_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * (5 + (_MSC_VER < 1900)))
106 #define nsrs_COMPILER_MSVC_VER 0
107 #define nsrs_COMPILER_MSVC_VERSION 0
110 #define nsrs_COMPILER_VERSION(major, minor, patch) \
111 (10 * (10 * (major) + (minor)) + (patch))
113 #if defined(__clang__)
114 #define nsrs_COMPILER_CLANG_VERSION \
115 nsrs_COMPILER_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
117 #define nsrs_COMPILER_CLANG_VERSION 0
120 #if defined(__GNUC__) && !defined(__clang__)
121 #define nsrs_COMPILER_GNUC_VERSION \
122 nsrs_COMPILER_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
124 #define nsrs_COMPILER_GNUC_VERSION 0
133 #define nsrs_HAS_CPP0X _HAS_CPP0X
135 #define nsrs_HAS_CPP0X 0
140 #if nsrs_COMPILER_MSVC_VER >= 1900
141 #undef nsrs_CPP11_OR_GREATER
142 #define nsrs_CPP11_OR_GREATER 1
145 #define nsrs_CPP11_90 (nsrs_CPP11_OR_GREATER_ || nsrs_COMPILER_MSVC_VER >= 1500)
146 #define nsrs_CPP11_100 (nsrs_CPP11_OR_GREATER_ || nsrs_COMPILER_MSVC_VER >= 1600)
147 #define nsrs_CPP11_110 (nsrs_CPP11_OR_GREATER_ || nsrs_COMPILER_MSVC_VER >= 1700)
148 #define nsrs_CPP11_120 (nsrs_CPP11_OR_GREATER_ || nsrs_COMPILER_MSVC_VER >= 1800)
149 #define nsrs_CPP11_140 (nsrs_CPP11_OR_GREATER_ || nsrs_COMPILER_MSVC_VER >= 1900)
151 #define nsrs_CPP14_000 (nsrs_CPP14_OR_GREATER)
152 #define nsrs_CPP17_000 (nsrs_CPP17_OR_GREATER)
157 #define nsrs_BETWEEN(v, lo, hi) ((lo) <= (v) && (v) < (hi))
161 #define nsrs_HAVE_CONSTEXPR_11 nsrs_CPP11_140
162 #define nsrs_HAVE_IS_DEFAULT nsrs_CPP11_140
163 #define nsrs_HAVE_IS_DELETE nsrs_CPP11_140
164 #define nsrs_HAVE_NOEXCEPT nsrs_CPP11_140
165 #define nsrs_HAVE_NULLPTR nsrs_CPP11_100
169 #define nsrs_HAVE_CONSTEXPR_14 nsrs_CPP14_000
179 #if defined(__clang__)
180 #pragma clang diagnostic push
181 #pragma clang diagnostic ignored "-Wundef"
182 #define nsrs_RESTORE_WARNINGS() _Pragma("clang diagnostic pop")
184 #elif defined __GNUC__
185 #pragma GCC diagnostic push
186 #pragma GCC diagnostic ignored "-Wundef"
187 #define nsrs_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop")
189 #elif nsrs_COMPILER_MSVC_VERSION >= 140
190 #define nsrs_DISABLE_MSVC_WARNINGS(codes) \
191 __pragma(warning(push)) __pragma(warning(disable : codes))
192 #define nsrs_RESTORE_WARNINGS() __pragma(warning(pop))
207 nsrs_DISABLE_MSVC_WARNINGS(4345 26439 26440 26472 26473 26481 26490)
210 #define nsrs_RESTORE_WARNINGS()
215 #if nsrs_HAVE_CONSTEXPR_11
216 #define nsrs_constexpr constexpr
218 #define nsrs_constexpr
221 #if nsrs_HAVE_CONSTEXPR_14
222 #define nsrs_constexpr14 constexpr
224 #define nsrs_constexpr14
227 #if nsrs_HAVE_NOEXCEPT
228 #define nsrs_noexcept noexcept
229 #define nsrs_noexcept_op noexcept
231 #define nsrs_noexcept
232 #define nsrs_noexcept_op(expr)
235 #if nsrs_HAVE_NULLPTR
236 #define nsrs_nullptr nullptr
238 #define nsrs_nullptr NULL
243 #if nsrs_CPP11_OR_GREATER
245 #define nsrs_REQUIRES_0(...) \
246 template <bool B = (__VA_ARGS__), typename std::enable_if<B, int>::type = 0>
248 #define nsrs_REQUIRES_T(...) , typename std::enable_if<(__VA_ARGS__), int>::type = 0
260 #if !nsrs_CPP11_OR_GREATER
266 namespace ring_span_lite
274 #if nsrs_CPP11_OR_GREATER
277 template <
typename T>
284 template <
bool B,
class T,
class F>
290 template <
class T,
class F>
303 #if nsrs_CPP17_OR_GREATER
305 using std::is_nothrow_swappable;
306 using std::is_swappable;
308 #elif nsrs_CPP11_OR_GREATER
317 template <typename T, typename = decltype(swap(std::declval<T&>(), std::declval<T&>()))>
324 struct is_nothrow_swappable
328 template <
typename T>
329 static constexpr
bool test()
331 return noexcept(
swap(std::declval<T&>(), std::declval<T&>()));
334 template <
typename T>
335 static auto test(
int) -> std::integral_constant<bool, test<T>()>
347 template <
typename T>
348 struct is_swappable : decltype(detail::is_swappable::test<T>(0))
352 template <
typename T>
353 struct is_nothrow_swappable : decltype(detail::is_nothrow_swappable::test<T>(0))
357 #endif // nsrs_CPP17_OR_GREATER
391 #if nsrs_RING_SPAN_LITE_EXTENSION
392 #if nsrs_CPP11_OR_GREATER
423 template <
class,
bool>
431 template <
class T,
class Popper = default_popper<T> >
447 #if nsrs_RING_SPAN_LITE_EXTENSION
454 template <
class ContiguousIterator>
465 template <
class ContiguousIterator>
477 #if nsrs_HAVE_IS_DEFAULT
512 #if nsrs_RING_SPAN_LITE_EXTENSION
578 #if nsrs_RING_SPAN_LITE_EXTENSION
623 #if nsrs_RING_SPAN_LITE_EXTENSION
635 #if nsrs_CPP11_OR_GREATER
636 nsrs_REQUIRES_0(std::is_copy_assignable<T>::value)
void push_back(
637 value_type const& value) noexcept(std::is_nothrow_copy_assignable<T>::value)
650 #if nsrs_CPP11_OR_GREATER
651 nsrs_REQUIRES_0(std::is_move_assignable<T>::value)
void push_back(
652 value_type&& value) noexcept(std::is_nothrow_move_assignable<T>::value)
662 template <
typename... Args nsrs_REQUIRES_T(
663 std::is_constructible<T, Args&&...>::value&& std::is_move_assignable<T>::value)>
664 void emplace_back(Args&&...
args) noexcept(
665 std::is_nothrow_constructible<T, Args...>::value &&
666 std::is_nothrow_move_assignable<T>::value)
673 back_() = T(std::forward<Args>(
args)...);
677 #if nsrs_RING_SPAN_LITE_EXTENSION
679 #if nsrs_CPP11_OR_GREATER
680 nsrs_REQUIRES_0(std::is_copy_assignable<T>::value)
void push_front(
681 T
const& value) noexcept((std::is_nothrow_copy_assignable<T>::value))
694 #if nsrs_CPP11_OR_GREATER
695 nsrs_REQUIRES_0(std::is_move_assignable<T>::value)
void push_front(T&& value) noexcept(
696 (std::is_nothrow_move_assignable<T>::value))
706 template <
typename... Args nsrs_REQUIRES_T(
707 std::is_constructible<T, Args&&...>::value&& std::is_move_assignable<T>::value)>
708 void emplace_front(Args&&...
args) noexcept(
709 std::is_nothrow_constructible<T, Args...>::value &&
710 std::is_nothrow_move_assignable<T>::value)
720 #endif // nsrs_RING_SPAN_LITE_EXTENSION
725 #if nsrs_CPP11_OR_GREATER
726 noexcept(std17::is_nothrow_swappable<Popper>::value)
818 template <
class T,
class Popper>
832 template<
class RS,
bool is_const >
833 class ring_iterator :
public std::iterator
835 std::random_access_iterator_tag
836 , typename std11::conditional<is_const, const typename RS::value_type, typename RS::value_type>::type
855 #if nsrs_CPP11_OR_GREATER
863 #if nsrs_RING_SPAN_LITE_EXTENSION
907 #if defined(__clang__) || defined(__GNUC__)
908 #pragma GCC diagnostic push
909 #pragma GCC diagnostic ignored "-Wsign-conversion"
924 #if defined(__clang__) || defined(__GNUC__)
925 #pragma GCC diagnostic pop
928 #if nsrs_RING_SPAN_LITE_EXTENSION
934 static_cast<difference_type
>(rhs.m_idx);
944 return (this->
m_idx < rhs.m_idx);
951 return (this->
m_idx == rhs.m_idx);
959 return !(*
this == rhs);
965 return !(rhs < *
this);
977 return !(*
this < rhs);
1002 template <
class RS,
bool C>
1009 template <
class RS,
bool C>
1019 using ring_span_lite::copy_popper;
1020 using ring_span_lite::default_popper;
1021 using ring_span_lite::null_popper;
1022 using ring_span_lite::ring_span;
1028 #endif // NONSTD_RING_SPAN_LITE_HPP
const_reverse_iterator crend() const nsrs_noexcept
const_reference front_() const nsrs_noexcept
auto first(const T &value, const Tail &...) -> const T &
reference back_() nsrs_noexcept
const_iterator end() const nsrs_noexcept
auto copy(const Range &range, OutputIt out) -> OutputIt
std::reverse_iterator< iterator > reverse_iterator
span_CONFIG_SIZE_TYPE size_t
reverse_iterator rbegin() nsrs_noexcept
reference front_() nsrs_noexcept
const_reference operator[](size_type idx) const nsrs_noexcept
size_type normalize_(size_type const idx) const nsrs_noexcept
type operator--(int) nsrs_noexcept
type operator++(int) nsrs_noexcept
const_reference back() const nsrs_noexcept
ring_span(ContiguousIterator begin, ContiguousIterator end, Popper popper=Popper()) nsrs_noexcept
void decrement_front_and_back_() nsrs_noexcept
integral_constant< bool, false > false_type
bool operator==(ring_iterator< RS, C > const &rhs) const nsrs_noexcept
const_reference front() const nsrs_noexcept
const_reverse_iterator rbegin() const nsrs_noexcept
std11::conditional< is_const, const value_type, value_type >::type * pointer
type & operator-=(int i) nsrs_noexcept
Popper::return_type pop_back()
std11::conditional< is_const, const RS, RS >::type ring_type
integral_constant< bool, true > true_type
type & operator++() nsrs_noexcept
bool operator<=(ring_iterator< RS, C > const &rhs) const nsrs_noexcept
T const & const_reference
void decrement_back_() nsrs_noexcept
ring_span< T, Popper > type
ring_iterator< RS, C > operator-(ring_iterator< RS, C > it, int i) nsrs_noexcept
#define nsrs_noexcept_op(expr)
ring_iterator< RS, C > operator+(ring_iterator< RS, C > it, int i) nsrs_noexcept
ring_iterator< RS, is_const > type
const_iterator begin() const nsrs_noexcept
RS::value_type value_type
ring_span & operator=(ring_span const &)
bool operator>=(ring_iterator< RS, C > const &rhs) const nsrs_noexcept
size_type capacity() const nsrs_noexcept
detail::ring_iterator< type, true > const_iterator
void decrement_front_() nsrs_noexcept
void operator()(T &) const nsrs_noexcept
reference at_(size_type idx) nsrs_noexcept
const_reference at_(size_type idx) const nsrs_noexcept
const_reverse_iterator rend() const nsrs_noexcept
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
const_reference back_() const nsrs_noexcept
const_iterator cend() const nsrs_noexcept
type & operator--() nsrs_noexcept
void increment_front_and_back_() nsrs_noexcept
void increment_front_() nsrs_noexcept
iterator begin() nsrs_noexcept
size_type size() const nsrs_noexcept
bool empty() const nsrs_noexcept
type & operator+=(int i) nsrs_noexcept
std11::conditional< is_const, const value_type, value_type >::type & reference
ring_span(ContiguousIterator begin, ContiguousIterator end, ContiguousIterator first, size_type size, Popper popper=Popper()) nsrs_noexcept
#define assert(condition)
bool operator>(ring_iterator< RS, C > const &rhs) const nsrs_noexcept
void push_front(T const &value)
T const & move(T const &t)
detail::ring_iterator< type, false > iterator
void increment_back_() nsrs_noexcept
difference_type operator-(ring_iterator< RS, C > const &rhs) const nsrs_noexcept
#define nsrs_RESTORE_WARNINGS()
reference operator*() const nsrs_noexcept
std::ptrdiff_t difference_type
reference front() nsrs_noexcept
reference back() nsrs_noexcept
reverse_iterator rend() nsrs_noexcept
bool full() const nsrs_noexcept
void push_back(value_type const &value)
std::reverse_iterator< const_iterator > const_reverse_iterator
std::random_access_iterator_tag iterator_category
Popper::return_type pop_front()
const_iterator cbegin() const nsrs_noexcept
const_reverse_iterator crbegin() const nsrs_noexcept
iterator end() nsrs_noexcept
ring_iterator(size_type idx, typename std11::conditional< is_const, const RS, RS >::type *rs) nsrs_noexcept
void swap(ring_span< T, Popper > &lhs, ring_span< T, Popper > &rhs) nsrs_noexcept_op(nsrs_noexcept_op(lhs.swap(rhs)))
bool operator<(ring_iterator< RS, C > const &rhs) const nsrs_noexcept
reference operator[](size_type idx) nsrs_noexcept
bool operator!=(ring_iterator< RS, C > const &rhs) const nsrs_noexcept
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46