-
Notifications
You must be signed in to change notification settings - Fork 6
/
general_back_inserter.hpp
58 lines (45 loc) · 1.23 KB
/
general_back_inserter.hpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @file general_back_inserter.hpp
* @brief
* @date 2019-10-7
* @author Peter
* @copyright
* Peter of [ThinkSpirit Laboratory](http://thinkspirit.org/)
* of [Nanjing University of Information Science & Technology](http://www.nuist.edu.cn/)
* all rights reserved
*/
#ifndef KERBAL_ITERATOR_GENERAL_BACK_INSERTER_HPP
#define KERBAL_ITERATOR_GENERAL_BACK_INSERTER_HPP
#include <kerbal/compatibility/constexpr.hpp>
#include <cstddef>
#include <iterator>
namespace kerbal
{
namespace iterator
{
template <typename Container>
struct general_back_insert_iterator
{
typedef std::back_insert_iterator<Container> type;
};
template <typename T>
struct general_back_insert_iterator<T[]>
{
typedef T * type;
};
template <typename T, std::size_t N>
struct general_back_insert_iterator<T[N]>
{
typedef T * type;
};
template <typename Container>
KERBAL_CONSTEXPR14
typename general_back_insert_iterator<Container>::type
general_inserter(Container & container)
{
typedef typename general_back_insert_iterator<Container>::type inserter;
return inserter(container);
}
} // namespace iterator
} // namespace kerbal
#endif // KERBAL_ITERATOR_GENERAL_BACK_INSERTER_HPP