tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_constant_evaluated.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_TYPE_TRAITS_IS_CONSTANT_EVALUATED_HPP
5#define TETL_TYPE_TRAITS_IS_CONSTANT_EVALUATED_HPP
6
7#include <etl/_config/all.hpp>
8
9namespace etl {
10
11/// \brief Detects whether the function call occurs within a constant-evaluated
12/// context. Returns true if the evaluation of the call occurs within the
13/// evaluation of an expression or conversion that is manifestly
14/// constant-evaluated; otherwise returns false.
15///
16/// https://en.cppreference.com/w/cpp/types/is_constant_evaluated
17[[nodiscard]] constexpr auto is_constant_evaluated() noexcept -> bool
18{
19#if __has_builtin(__builtin_is_constant_evaluated)
20 return __builtin_is_constant_evaluated();
21#else
22 return false;
23#endif
24}
25
26} // namespace etl
27
28#endif // TETL_TYPE_TRAITS_IS_CONSTANT_EVALUATED_HPP
Definition adjacent_find.hpp:9
constexpr auto is_constant_evaluated() noexcept -> bool
Detects whether the function call occurs within a constant-evaluated context. Returns true if the eva...
Definition is_constant_evaluated.hpp:17