Skip to content

Commit 4eff9f6

Browse files
committed
Add example C++ code base for testing
1 parent 67e6a0c commit 4eff9f6

File tree

5 files changed

+372
-0
lines changed

5 files changed

+372
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ccls and clangd caches
22
.ccls-cache/
33
.clangd/
4+
.cache/
45

56
# build directories
67
build*/

example/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ccls and clangd caches
2+
.ccls-cache/
3+
.clangd/
4+
.cache/
5+
6+
# build directories
7+
build*/
8+
9+
# hdoc output and test files
10+
hdoc-test/
11+
hdoc-output/

example/.hdoc.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[project]
2+
name = "example"
3+
version = "0.0.1"
4+
git_repo_url = "https://github.com/example/example/"
5+
git_default_branch = "main"
6+
7+
[paths]
8+
compile_commands = "build/compile_commands.json"
9+
output_dir = "hdoc-output"
10+
11+
[includes]
12+
paths = []
13+
use_system_includes = true
14+
15+
[ignore]
16+
paths = [
17+
"/tests/",
18+
"/subprojects/",
19+
]
20+
21+
[pages]
22+
homepage = "README.md"

example/example.cpp

Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
#include <functional>
2+
#include <string>
3+
#include <tuple>
4+
#include <vector>
5+
6+
#define EXAMPLE_MACRO_CONST 123
7+
#define EXAMPLE_MACRO_FUNC(x) ((x) + 1)
8+
9+
#define EXAMPLE_MACRO_DEFINE_STRUCT(name) \
10+
struct macro_##name {};
11+
12+
#define EXAMPLE_MACRO_DEFINE_OPERATOR(name, ret, op) ret operator op(const name&) const;
13+
14+
namespace example {
15+
16+
EXAMPLE_MACRO_DEFINE_STRUCT(struct)
17+
18+
struct struct_with_macro_expansions {
19+
EXAMPLE_MACRO_DEFINE_STRUCT(nested_struct)
20+
EXAMPLE_MACRO_DEFINE_OPERATOR(struct_with_macro_expansions, bool, ==)
21+
EXAMPLE_MACRO_DEFINE_OPERATOR(struct_with_macro_expansions, bool, !=)
22+
};
23+
24+
enum unscoped_enum { u_value1 = -1, u_value2, u_value3, u_value4 };
25+
enum unscoped_int_enum : int { ui_value1 = -1, ui_value2, ui_value3, ui_value4 };
26+
enum class scoped_enum { value1, value2, value3 = value2, value4 };
27+
enum class scoped_int_enum : int { value1, value2, value3 = value2, value4 };
28+
29+
using alias = int;
30+
typedef int alias_typedef;
31+
template <typename T> using alias_template = std::vector<T>;
32+
template <typename... T> using alias_variadic_template = std::tuple<T...>;
33+
template <template <typename...> typename T> using alias_template_template = T<int>;
34+
35+
struct forward_struct;
36+
template <typename T> struct forward_struct_template;
37+
template <typename T> using forward_struct_value_type = typename forward_struct_template<T>::value_type;
38+
39+
class class_with_deleted_special_members {
40+
public:
41+
class_with_deleted_special_members() = delete;
42+
class_with_deleted_special_members(const class_with_deleted_special_members&) = delete;
43+
class_with_deleted_special_members(class_with_deleted_special_members&&) = delete;
44+
class_with_deleted_special_members& operator=(const class_with_deleted_special_members&) = delete;
45+
class_with_deleted_special_members& operator=(class_with_deleted_special_members&&) = delete;
46+
~class_with_deleted_special_members() = delete;
47+
};
48+
49+
class class_with_defaulted_special_members {
50+
public:
51+
class_with_defaulted_special_members() = default;
52+
class_with_defaulted_special_members(const class_with_defaulted_special_members&) = default;
53+
class_with_defaulted_special_members(class_with_defaulted_special_members&&) = default;
54+
class_with_defaulted_special_members& operator=(const class_with_defaulted_special_members&) = default;
55+
class_with_defaulted_special_members& operator=(class_with_defaulted_special_members&&) = default;
56+
~class_with_defaulted_special_members() = default;
57+
};
58+
59+
class class_with_hidden_friends {
60+
public:
61+
friend bool operator==(const class_with_hidden_friends& first, const class_with_hidden_friends& second);
62+
friend bool operator++(class_with_hidden_friends& self);
63+
friend void swap(class_with_hidden_friends& first, class_with_hidden_friends& second) noexcept;
64+
template <typename... Ts> friend auto fold(class_with_hidden_friends& head, Ts&&... tail);
65+
};
66+
67+
template<typename T>
68+
class template_class_with_hidden_friends {
69+
public:
70+
friend bool operator==(const template_class_with_hidden_friends& first,
71+
const template_class_with_hidden_friends& second);
72+
friend bool operator++(template_class_with_hidden_friends& self);
73+
friend void swap(template_class_with_hidden_friends& first, template_class_with_hidden_friends& second) noexcept;
74+
template <typename... Ts> friend auto fold(template_class_with_hidden_friends& head, Ts&&... tail);
75+
};
76+
77+
class abstract_class {
78+
public:
79+
virtual ~abstract_class() = 0;
80+
virtual void public_foo() = 0;
81+
virtual void public_bar() const = 0;
82+
83+
protected:
84+
abstract_class() = default;
85+
virtual void protected_baz() = 0;
86+
87+
private:
88+
virtual void private_qux() = 0;
89+
};
90+
91+
class overriding_class : public abstract_class {
92+
public:
93+
~overriding_class() override;
94+
void public_foo() override;
95+
void public_bar() const final;
96+
};
97+
98+
class final_class final : public overriding_class {
99+
public:
100+
void public_foo() final;
101+
};
102+
103+
struct struct_with_qualified_members {
104+
struct constexpr_tag;
105+
struct inline_tag;
106+
struct explicit_tag;
107+
struct noexcept_tag;
108+
109+
struct_with_qualified_members() = default;
110+
struct_with_qualified_members(const struct_with_qualified_members&) noexcept;
111+
struct_with_qualified_members(struct_with_qualified_members&&) noexcept;
112+
struct_with_qualified_members& operator=(const struct_with_qualified_members&) noexcept;
113+
struct_with_qualified_members& operator=(struct_with_qualified_members&&) noexcept;
114+
~struct_with_qualified_members() noexcept(false) = default;
115+
116+
constexpr struct_with_qualified_members(constexpr_tag);
117+
inline struct_with_qualified_members(inline_tag);
118+
explicit struct_with_qualified_members(explicit_tag);
119+
struct_with_qualified_members(noexcept_tag) noexcept;
120+
121+
int member;
122+
const int const_member;
123+
mutable int mutable_member;
124+
volatile int volatile_member;
125+
const volatile int const_volatile_member;
126+
mutable volatile int mutable_volatile_member;
127+
128+
static int static_member;
129+
static const int static_const_member;
130+
static volatile int static_volatile_member;
131+
static const volatile int static_const_volatile_member;
132+
133+
inline static int inline_static_member;
134+
inline static const int inline_static_const_member = 0;
135+
inline static constexpr int inline_static_constexpr_member = 0;
136+
inline static volatile int inline_static_volatile_member;
137+
inline static const volatile int inline_static_const_volatile_member = 0;
138+
inline static constexpr volatile int inline_static_constexpr_volatile_member = 0;
139+
140+
inline int inline_member_fn();
141+
constexpr int inline_member_fn() const;
142+
int noexcept_member_fn() noexcept;
143+
144+
int value_member_fn();
145+
int value_member_fn() const;
146+
int value_member_fn() volatile;
147+
int value_member_fn() const volatile;
148+
149+
int ref_member_fn() &;
150+
int ref_member_fn() const&;
151+
int ref_member_fn() volatile&;
152+
int ref_member_fn() const volatile&;
153+
int ref_member_fn() &&;
154+
int ref_member_fn() const&&;
155+
int ref_member_fn() volatile&&;
156+
int ref_member_fn() const volatile&&;
157+
158+
operator int() const;
159+
160+
operator float&();
161+
operator const float&() const;
162+
operator volatile float&() volatile;
163+
operator const volatile float&() const volatile;
164+
165+
explicit operator bool() const;
166+
167+
template <bool Noexcept> void conditionally_noexcept_member_fn() noexcept(Noexcept);
168+
};
169+
170+
struct struct_with_aliases {
171+
using alias = int;
172+
typedef int alias_typedef;
173+
template <typename T> using vector = std::vector<T>;
174+
template <template <typename...> typename T> using apply = T<int>;
175+
};
176+
177+
template <typename T, typename U> struct struct_template_with_aliases {
178+
using alias = T;
179+
typedef int alias_typedef;
180+
using value_type = typename U::value_type;
181+
template <typename V> using vector = std::vector<V>;
182+
template <template <typename...> typename V> using apply = V<T, U>;
183+
};
184+
185+
template <typename T, typename U> using dependent_alias = typename T::template vector<U>;
186+
187+
struct struct_with_private_members {
188+
protected:
189+
using protected_type = int;
190+
struct_with_private_members(int);
191+
int protected_member;
192+
template <typename T> void protected_member_fn(T);
193+
194+
private:
195+
using private_type = int;
196+
struct_with_private_members(int, int);
197+
int private_member;
198+
template <typename T> void private_member_fn(T);
199+
};
200+
201+
struct struct_exporting_base_members : struct_with_private_members {
202+
using struct_with_private_members::protected_member;
203+
using struct_with_private_members::protected_member_fn;
204+
using struct_with_private_members::struct_with_private_members;
205+
using typename struct_with_private_members::protected_type;
206+
};
207+
208+
struct struct_with_nested_struct {
209+
struct nested_struct {};
210+
template <typename T> struct nested_struct_template {};
211+
};
212+
213+
template <typename T> struct template_struct_with_nested_struct {
214+
struct nested_struct {};
215+
template <typename U = T> struct nested_struct_template {};
216+
};
217+
218+
struct struct_with_friends {
219+
friend void undeclared_friend_fn();
220+
template <typename T> friend void undeclared_template_friend_fn(T);
221+
};
222+
223+
struct forward_partial_specialization;
224+
struct defined_partial_specialization;
225+
struct full_specialization;
226+
227+
template <typename...> struct struct_template;
228+
229+
template <typename... T> struct struct_template<forward_partial_specialization, T...>;
230+
231+
template <typename... T> struct struct_template<defined_partial_specialization, T...> {
232+
using next = struct_template<T...>;
233+
using type = typename next::type;
234+
};
235+
236+
template <> struct struct_template<full_specialization> {
237+
using type = int;
238+
};
239+
240+
template <template <typename...> typename T> struct struct_template_over_templates {
241+
template <typename... U> using type = T<U...>;
242+
};
243+
244+
template <> struct struct_template_over_templates<std::tuple> {
245+
using type = void;
246+
};
247+
248+
}; // namespace example
249+
250+
namespace example::functions {
251+
252+
void function();
253+
int function_returns();
254+
const int function_returns_const();
255+
volatile int function_returns_volatile();
256+
const volatile int function_returns_const_volatile();
257+
auto function_with_trailing_ret() -> int;
258+
auto function_with_auto_ret() -> int;
259+
decltype(auto) function_with_decltype_auto_ret();
260+
decltype(0) function_with_decltype_ret();
261+
262+
template <typename... Ts> void function_template(Ts const&...);
263+
template <> void function_template<int, char>(int const&, char const&);
264+
template <template <typename...> typename T> void function_template_over_templates(T<int, float, void>&& v);
265+
template <>
266+
void function_template_over_templates<alias_variadic_template>(alias_variadic_template<int, float, void>&& v);
267+
268+
template <typename T> auto function_with_decltype_ret(T a, T b) -> decltype(a + b);
269+
270+
void noexcept_function() noexcept;
271+
[[noreturn]] void noreturn_function();
272+
[[nodiscard]] int nodiscard_function();
273+
[[nodiscard("nodiscard reason")]] int nodiscard_reason_function();
274+
[[deprecated]] int deprecated_function();
275+
[[deprecated("deprecation reason")]] int deprecated_reason_function();
276+
277+
void function_with_qualified_args(const int ci,
278+
volatile int vi,
279+
const volatile int cvi,
280+
int *pi,
281+
int *const cpi,
282+
int *volatile vpi,
283+
int *const volatile cvpi,
284+
int&& rvi,
285+
const int& cri,
286+
volatile int&& vrvi,
287+
const volatile int&& cvrvi);
288+
void function_with_unused_args([[maybe_unused]] int p, int /* q */);
289+
290+
} // namespace example::functions
291+
292+
namespace example::variables {
293+
294+
int global_variable;
295+
extern int global_extern_variable;
296+
static int global_static_variable;
297+
298+
template <int V> int global_variable_template = V;
299+
template <int V> const int global_const_variable_template = V;
300+
template <int V> constexpr int global_constexpr_variable_template = V;
301+
template <int V> inline constexpr int global_inline_constexpr_variable_template = V;
302+
303+
} // namespace example::variables
304+
305+
namespace example::detail {
306+
struct detail_struct {};
307+
} // namespace example::detail
308+
309+
namespace example::other::detail {
310+
struct other_struct {};
311+
} // namespace example::other::detail
312+
313+
namespace example::other::detail {
314+
struct other_detail_struct {};
315+
} // namespace example::other::detail
316+
317+
namespace example::detail::nested_detail {
318+
struct nested_detail_struct {};
319+
} // namespace example::detail::nested_detail
320+
321+
struct global_namespace_struct {};
322+
int global_variable;
323+
324+
template <> struct std::hash<example::unscoped_enum> {
325+
std::size_t operator()(example::unscoped_enum value) const;
326+
};
327+
328+
template <typename... T> struct std::hash<example::struct_template<T...>> {
329+
std::size_t operator()(example::struct_template<T...> value) const;
330+
};
331+
332+
template <template <typename...> typename T> struct std::hash<example::struct_template_over_templates<T>> {
333+
std::size_t operator()(example::struct_template_over_templates<T> value) const;
334+
};

example/meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
project('example', 'cpp')
2+
3+
# Define the library
4+
example_lib = library('example', 'example.cpp')

0 commit comments

Comments
 (0)