-
Notifications
You must be signed in to change notification settings - Fork 1
/
super-awesome-library-that-has-breaking-changes-frequently.hpp
113 lines (94 loc) · 2.52 KB
/
super-awesome-library-that-has-breaking-changes-frequently.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef SUPER_AWESOME_LIBRARY_THAT_HAS_BREAKING_CHANGES_FREQUENTLY_HPP_INCLUDED_
#define SUPER_AWESOME_LIBRARY_THAT_HAS_BREAKING_CHANGES_FREQUENTLY_HPP_INCLUDED_
#include<cstddef>
#include<vector>
#include<string>
#if SUPER_AWESOME_LIBRARY_THAT_HAS_BREAKING_CHANGES_FREQUENTLY_VERSION == 1
namespace super_awesome_library_that_has_breaking_changes_frequently{
enum class super_flags{
super
};
struct awesome_type{
static constexpr int values[] = {0, 1, 2, 3, 4};
constexpr int a(std::size_t i)const{
return values[i % 4u];
}
constexpr const int* b(std::size_t i)const{
if(i >= 5)
return nullptr;
return values+i;
}
};
template<typename... Args>
static constexpr int c(Args&&...){
return __LINE__ + sizeof...(Args);
}
struct excellent_type{
excellent_type() = default;
virtual void d(int) = 0;
struct hyper_data{
std::string value;
};
std::size_t hyper_size()const{
return data.size();
}
const std::string& access_hyper_data(std::size_t index)const{
return data[index].value;
}
private:
std::vector<hyper_data> data = {{"super"}, {"duper"}, {"hyper"}};
};
static void use_d(excellent_type& et){
et.d(__LINE__);
}
}
#elif SUPER_AWESOME_LIBRARY_THAT_HAS_BREAKING_CHANGES_FREQUENTLY_VERSION == 2
#include<optional>
namespace super_awesome_library_that_has_breaking_changes_frequently{
enum class super_flags{
super,
duper
};
struct awesome_type{
static constexpr int values[] = {0, 1, 2, 3, 4};
constexpr int a2(std::size_t i)const{
return values[i % 4u];
}
constexpr std::optional<const int*> b(std::size_t i)const{
if(i >= 5)
return std::nullopt;
return {values+i};
}
template<typename... Args>
static constexpr int c(Args&&...){
return __LINE__ + sizeof...(Args);
}
};
struct excellent_type{
excellent_type() = default;
virtual void d(int, super_flags) = 0;
class hyper_data{
std::string value;
public:
hyper_data(std::string v):value{std::move(v)}{}
const std::string& access()const{
return value;
}
};
class hyper_range{
const excellent_type* t;
public:
hyper_range(const excellent_type* self):t{self}{}
auto begin()const{return t->data.begin();}
auto end()const{return t->data.end();}
};
hyper_range hypers()const{return hyper_range{this};}
private:
std::vector<hyper_data> data = {{"super"}, {"duper"}, {"hyper"}};
};
static void use_d(excellent_type& et){
et.d(__LINE__, super_flags::super);
}
}
#endif
#endif//SUPER_AWESOME_LIBRARY_THAT_HAS_BREAKING_CHANGES_FREQUENTLY_HPP_INCLUDED_