InsightsStrongTypes.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * C++ Insights, copyright (C) by Andreas Fertig
4 * Distributed under an MIT license. See LICENSE for details
5 *
6 ****************************************************************************/
7
8#ifndef INSIGHTS_STRONG_TYPES
9#define INSIGHTS_STRONG_TYPES
10
11/// \brief A more than simple typsafe \c bool
12///
13/// This macro creates a class enum with two enumerators:
14/// - \c No
15/// - \c Yes
16///
17/// Usage:
18/// \code
19/// STRONG_BOOL(AddNewLine);
20/// void Foo(AddNewLine);
21/// ...
22/// void Bar() {
23/// Foo(AddNewLine::Yes);
24/// }
25/// \endcode
26#define STRONG_BOOL(typeName) \
27 enum class typeName : bool \
28 { \
29 No = false, \
30 Yes = true \
31 }
32
33#endif /* INSIGHTS_STRONG_TYPES */