cppx-core
Truth.hpp
Go to the documentation of this file.
1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi").
2 
8 #include <cppx-core/language/syntax/macro-use.hpp> // CPPX_USE_STD
9 #include <cppx-core/language/tmp/basic-Enable_if_.hpp> // cppx::Enable_if_
10 
11 #include <type_traits> // std::is_same_v
12 
13 namespace cppx
14 {
15  CPPX_USE_STD( enable_if_t, is_same_v );
16 
34  class Truth
35  {
36  bool m_value;
37 
38  template< class T >
39  static constexpr bool is_bool_ = std::is_same_v<T, bool>;
40 
41  public:
46  template<
47  class Result,
49  >
50  constexpr operator Result() const noexcept { return m_value; }
51 
55  template<
56  class Arg,
58  >
59  constexpr Truth( const Arg value ) noexcept: m_value( value ) {}
60  };
61 } // namespace cppx
constexpr Truth(const Arg value) noexcept
Construction from bool (only).
Definition: Truth.hpp:59
A drop-in replacement for bool without implicit conversion from/to types other than bool.
Definition: Truth.hpp:34
Enable_if_ is just more readable than enable_if_t.
CPPX_USE_STD(basic_string, basic_string_view, bitset, char_traits, size)
std::enable_if_t< condition, Result > Enable_if_
Just more readable than enable_if_t.
Macros for generating more concise and clear using statements, primarily $use_cppx and $use_std,...