Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
conditional.hpp
Go to the documentation of this file.
1
// Copyright 2024, Toyota Motor Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_CONDITIONAL_HPP_
6
#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_CONDITIONAL_HPP_
7
8
// parasoft-begin-suppress CERT_CPP-DCL58-a-2 "Part of a standard library implementation"
9
// parasoft-begin-suppress AUTOSAR-A17_6_1-a-2 "Part of a standard library implementation"
10
11
// IWYU pragma: private, include <type_traits>
12
13
namespace
std
{
14
15
/// @brief Helper template for selecting types based on a condition. If the supplied @c Condition is @c true then the
16
/// nested @c type member is an alias for @c TrueType otherwise it is an alias for @c FalseType
17
/// @tparam Condition The condition
18
/// @tparam TrueType The type to use if the condition is @c true
19
/// @tparam FalseType The type to use if the condition is @c false
20
template
<
bool
Condition,
typename
TrueType,
typename
FalseType>
21
class
conditional
{
22
public
:
23
/// @brief The selected type
24
using
type
= FalseType;
25
};
26
27
// parasoft-begin-suppress AUTOSAR-A14_7_2-a-2 "False positive: All
28
// 'conditional' specializations are declared in the same files as the
29
// primary template"
30
31
// parasoft-begin-suppress AUTOSAR-A2_7_3-a "False positive: all declarations
32
// and typedefs *are* preceded by a comment with @brief"
33
34
/// @brief Helper template for selecting types based on a condition. If the supplied @c Condition is @c true then the
35
/// nested @c type member is an alias for @c TrueType otherwise it is an alias for @c FalseType
36
///
37
/// This specialization handles the case that the condition is @c true
38
/// @tparam TrueType The type to use if the condition is @c true
39
/// @tparam FalseType The type to use if the condition is @c false
40
template
<
typename
TrueType,
typename
FalseType>
41
class
conditional
<true, TrueType, FalseType> {
42
public
:
43
/// @brief The selected type
44
using
type
= TrueType;
45
};
46
47
// parasoft-end-suppress AUTOSAR-A2_7_3-a
48
// parasoft-end-suppress AUTOSAR-A14_7_2-a-2
49
50
// parasoft-begin-suppress AUTOSAR-A2_7_3-a "False positive: the typedef *is* preceded by a comment with @brief"
51
/// @brief Helper template alias for selecting types based on a condition. If the supplied @c Condition is @c true then
52
/// it is an alias for @c TrueType otherwise it is an alias for @c FalseType
53
/// @tparam Condition The condition
54
/// @tparam TrueType The type to use if the condition is @c true
55
/// @tparam FalseType The type to use if the condition is @c false
56
template
<
bool
Condition,
typename
TrueType,
typename
FalseType>
57
using
conditional_t
=
typename
conditional<Condition, TrueType, FalseType>::type
;
58
// parasoft-end-suppress AUTOSAR-A2_7_3-a
59
60
}
// namespace std
61
62
#endif
// INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_CONDITIONAL_HPP_
std::conditional< true, TrueType, FalseType >::type
TrueType type
The selected type.
Definition
conditional.hpp:44
std::conditional
Helper template for selecting types based on a condition. If the supplied Condition is true then the ...
Definition
conditional.hpp:21
std::conditional::type
FalseType type
The selected type.
Definition
conditional.hpp:24
std
STL namespace.
std::conditional_t
typename conditional< Condition, TrueType, FalseType >::type conditional_t
Helper template alias for selecting types based on a condition. If the supplied Condition is true the...
Definition
conditional.hpp:57
stdlib
include
stdlib_detail
conditional.hpp
Generated by
1.13.2