EtcPal  HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
View other versions:
common.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2022 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************
16  * This file is a part of EtcPal. For more information, go to:
17  * https://github.com/ETCLabs/EtcPal
18  ******************************************************************************/
19 
22 
23 #ifndef ETCPAL_CPP_COMMON_H_
24 #define ETCPAL_CPP_COMMON_H_
25 
43 
48 
49 #if ((defined(_MSC_VER) && (_MSC_VER > 1900)) || (__cplusplus >= 201402L))
50 #define ETCPAL_CONSTEXPR_14 constexpr
51 #define ETCPAL_CONSTEXPR_14_OR_INLINE constexpr
52 #else
53 #define ETCPAL_CONSTEXPR_14
54 #define ETCPAL_CONSTEXPR_14_OR_INLINE inline
55 #endif
56 
63 #if DOXYGEN
64 #define ETCPAL_NO_EXCEPTIONS
65 #endif
66 
68 
69 #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(ETCPAL_NO_EXCEPTIONS)
70 #define ETCPAL_THROW(exception) throw exception
71 #define ETCPAL_BUILDING_WITH_EXCEPTIONS 1
72 #else
73 #include <cstdlib>
74 #define ETCPAL_THROW(exception) std::abort()
75 #define ETCPAL_BUILDING_WITH_EXCEPTIONS 0
76 #endif
77 
79 
81 
82 namespace etcpal
83 {
85 
86 namespace detail
87 {
88 enum class Enabler
89 {
90 };
91 
92 #define ETCPAL_ENABLE_IF_ARG(...) typename std::enable_if<(__VA_ARGS__)>::type* = nullptr
93 #define ETCPAL_ENABLE_IF_TEMPLATE(...) typename = typename std::enable_if<(__VA_ARGS__), detail::Enabler>::type
94 
95 } // namespace detail
96 
98 } // namespace etcpal
99 
100 #endif // ETCPAL_CPP_COMMON_H_