-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathcpp_static_assert.hpp
More file actions
50 lines (40 loc) · 1.5 KB
/
cpp_static_assert.hpp
File metadata and controls
50 lines (40 loc) · 1.5 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
45
46
47
48
49
50
// Copyright (C) 2017-2023 Jonathan Müller and cppast contributors
// SPDX-License-Identifier: MIT
#ifndef CPPAST_CPP_STATIC_ASSERT_HPP_INCLUDED
#define CPPAST_CPP_STATIC_ASSERT_HPP_INCLUDED
#include <cppast/cpp_entity.hpp>
#include <cppast/cpp_expression.hpp>
namespace cppast
{
class cpp_static_assert : public cpp_entity
{
public:
static cpp_entity_kind kind() noexcept;
/// \returns A newly created `static_assert()` entity.
/// \notes It will not be registered as nothing can refer to it.
static std::unique_ptr<cpp_static_assert> build(std::unique_ptr<cpp_expression> expr,
std::string msg)
{
return std::unique_ptr<cpp_static_assert>(
new cpp_static_assert(std::move(expr), std::move(msg)));
}
/// \returns A reference to the [cppast::cpp_expression]() that is being asserted.
const cpp_expression& expression() const noexcept
{
return *expr_;
}
/// \returns A reference to the message of the assertion.
const std::string& message() const noexcept
{
return msg_;
}
private:
cpp_static_assert(std::unique_ptr<cpp_expression> expr, std::string msg)
: cpp_entity(""), expr_(std::move(expr)), msg_(std::move(msg))
{}
cpp_entity_kind do_get_entity_kind() const noexcept override;
std::unique_ptr<cpp_expression> expr_;
std::string msg_;
};
} // namespace cppast
#endif // CPPAST_CPP_STATIC_ASSERT_HPP_INCLUDED