-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiter_traits.hpp
More file actions
44 lines (33 loc) · 1 KB
/
iter_traits.hpp
File metadata and controls
44 lines (33 loc) · 1 KB
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
34
35
36
37
38
39
40
41
42
43
44
//
// Created by Yury Rakhuba on 24/07/15.
//
#pragma once
#include <type_traits>
#include <iterator>
namespace iter
{
template<typename TIter, typename TIterTag>
struct BaseIterCheck
{
constexpr static bool value = std::is_base_of<TIterTag, typename std::iterator_traits<TIter>::iterator_category>::value;
};
template<typename TIter>
struct RandomAccessIterCheck : BaseIterCheck<TIter, std::random_access_iterator_tag> {};
template<typename TIter>
struct BidirIterCheck : BaseIterCheck<TIter, std::bidirectional_iterator_tag> {};
template<typename TIter>
struct ForwardIterCheck : BaseIterCheck<TIter, std::forward_iterator_tag> {};
template<typename TIter>
struct OutputIterCheck : BaseIterCheck<TIter, std::output_iterator_tag> {};
template<typename TIter>
void SwapValues(TIter & iter1, TIter & iter2)
{
std::swap(*iter1, *iter2);
}
template<typename TIter>
TIter NextIter(TIter const & iter, typename std::iterator_traits<TIter>::difference_type n = 1)
{
TIter copy = iter;
return std::next(copy, n);
}
}