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
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once


#include <type_traits><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.


#include "adaptor/valarray.hpp"
#include "adaptor/map.hpp"

#include "internal/resolving_rank.hpp"


namespace uni {

namespace internal {

namespace auto_holder_impl {


template<class T, bool DYNAMIC, class = std::enable_if_t<std::is_integral_v<T> && not DYNAMIC>>
constexpr int _holder_type(resolving_rank<2>) { return 0; }

template<class T, bool>
constexpr auto _holder_type(resolving_rank<1>) -> decltype(std::unordered_set<T>(), 0){ return 1; }

template<class T, bool>
constexpr int _holder_type(resolving_rank<0>) { return 2; }


template<class T, bool DYNAMIC = false>
constexpr int holder_type = _holder_type<T,DYNAMIC>(resolving_rank<10>{});


template<class,class,int> struct holder {};

template<class T, class U>
struct holder<T, U, 0> : vector<U> {
    using vector<U>::vector;
};

template<class T, class U>
struct holder<T, U, 1> : gp_hash_table<T, U> {
    using gp_hash_table<T, U>::gp_hash_table;

    template<class V> inline void assign(const internal::size_t, const V& v) { this->set_default(v); }
};

template<class T, class U>
struct holder<T, U, 2> : map<T, U> {
    using map<T, U>::map;

    template<class V> inline void assign(const internal::size_t, const V& v) { this->set_default(v); }
};


} // namespace auto_holder_impl

} // namespace internal


template<class T, class U> struct auto_holder : internal::auto_holder_impl::holder<T,U,internal::auto_holder_impl::holder_type<T>> {
    using internal::auto_holder_impl::holder<T,U,internal::auto_holder_impl::holder_type<T>>::holder;
};

template<class T, class U> struct dynamic_auto_holder : internal::auto_holder_impl::holder<T,U,internal::auto_holder_impl::holder_type<T,true>> {
    using internal::auto_holder_impl::holder<T,U,internal::auto_holder_impl::holder_type<T,true>>::holder;
};


} // namespace uni