12 #ifndef PLSSVM_DEFAULT_VALUE_HPP_ 
   13 #define PLSSVM_DEFAULT_VALUE_HPP_ 
   22 #include <type_traits>   
   41     constexpr 
default_init() noexcept(std::is_nothrow_default_constructible_v<T>) = default;
 
   46     constexpr explicit 
default_init(T val) noexcept(std::is_nothrow_move_constructible_v<T>) :
 
   47         value{ std::move_if_noexcept(val) } {}
 
   90         value_ = std::move_if_noexcept(non_default_val);
 
  101     template <
typename U, PLSSVM_REQUIRES(std::is_convertible_v<U, value_type>)>
 
  112     template <
typename U, PLSSVM_REQUIRES(std::is_convertible_v<U, value_type>)>
 
  124     template <
typename U, PLSSVM_REQUIRES(std::is_convertible_v<U, value_type>)>
 
  138     template <
typename U, PLSSVM_REQUIRES(std::is_convertible_v<U, value_type>)>
 
  156     [[nodiscard]] constexpr 
operator const value_type &() 
const noexcept {
 
  157         return this->
value();
 
  207 template <
typename T>
 
  209     return out << val.
value();
 
  219 template <
typename T>
 
  231 template <
typename T>
 
  243 template <
typename T>
 
  245     return lhs.value() == rhs.value();
 
  250 template <
typename T>
 
  252     return lhs.value() == rhs;
 
  257 template <
typename T>
 
  259     return lhs == rhs.value();
 
  269 template <
typename T>
 
  271     return !(lhs == rhs);
 
  276 template <
typename T>
 
  278     return !(lhs == rhs);
 
  283 template <
typename T>
 
  285     return !(lhs == rhs);
 
  295 template <
typename T>
 
  297     return lhs.value() < rhs.value();
 
  302 template <
typename T>
 
  304     return lhs.value() < rhs;
 
  309 template <
typename T>
 
  311     return lhs < rhs.value();
 
  321 template <
typename T>
 
  329 template <
typename T>
 
  331     return lhs.value() > rhs;
 
  337 template <
typename T>
 
  339     return lhs > rhs.value();
 
  349 template <
typename T>
 
  356 template <
typename T>
 
  358     return !(lhs.value() > rhs);
 
  363 template <
typename T>
 
  365     return !(lhs > rhs.value());
 
  375 template <
typename T>
 
  382 template <
typename T>
 
  384     return !(lhs.value() < rhs);
 
  389 template <
typename T>
 
  391     return !(lhs < rhs.value());
 
  402 template <
typename T>
 
  403 struct is_default_value : std::false_type {};
 
  409 template <
typename T>
 
  410 struct is_default_value<default_value<T>> : std::true_type {};
 
  419 template <
typename T>
 
  420 struct is_default_value : detail::is_default_value<std::remove_cv_t<std::remove_reference_t<T>>> {};  
 
  424 template <
typename T>
 
  435 template <
typename T>
 
  444         return std::hash<T>{}(val.value());
 
This class encapsulates a value that may be a default value or not.
Definition: default_value.hpp:62
bool use_default_init_
Flag used to determine whether the default value should be used or the user defined value.
Definition: default_value.hpp:195
constexpr default_value & operator=(value_type non_default_val) noexcept(std::is_nothrow_move_assignable_v< value_type >)
Override the previously provided default value with the new, non-default value.
Definition: default_value.hpp:89
value_type value_
The wrapped value to be used if use_default_init_ is false.
Definition: default_value.hpp:193
constexpr default_value(default_value< U > &&other) noexcept(std::is_nothrow_move_constructible_v< U >)
Move-construct a new default_value_from a possibly other type.
Definition: default_value.hpp:113
constexpr void swap(default_value &other) noexcept(std::is_nothrow_swappable_v< T >)
Swap the content of two default_values.
Definition: default_value.hpp:178
constexpr default_value(const default_value< U > &other) noexcept(std::is_nothrow_copy_constructible_v< U >)
Copy-construct a new default_value from a possibly other type.
Definition: default_value.hpp:102
constexpr default_value & operator=(default_value< U > &&other) noexcept(std::is_nothrow_move_assignable_v< U >)
Move-assign a new default_value from a possible other type.
Definition: default_value.hpp:139
T value_type
The type encapsulated by this default_value.
Definition: default_value.hpp:74
constexpr const value_type & value() const noexcept
Get the currently active value: the user provided value if provided, otherwise the default value is r...
Definition: default_value.hpp:150
constexpr const value_type & get_default() const noexcept
Get the default value even if it has already been overwritten by the user.
Definition: default_value.hpp:163
default_init< value_type > default_init_
The wrapped default value used if use_default_init_ is true.
Definition: default_value.hpp:197
constexpr bool is_default() const noexcept
Check whether the currently active value is the default value.
Definition: default_value.hpp:170
constexpr default_value(default_init< value_type > default_val=default_init< value_type >{}) noexcept(std::is_nothrow_move_constructible_v< value_type >)
Copy construct a default_value object using the provided default value.
Definition: default_value.hpp:81
constexpr void reset() noexcept
Set the current active value back to the default value.
Definition: default_value.hpp:187
constexpr default_value & operator=(const default_value< U > &other) noexcept(std::is_nothrow_copy_assignable_v< U >)
Copy-assign a new default_value from a possible other type.
Definition: default_value.hpp:125
The main namespace containing all public API functions.
Definition: backend_types.hpp:24
constexpr bool is_default_value_v
Test whether the given type T is of type plssvm::default_value ignoring all top-level const,...
Definition: default_value.hpp:425
constexpr void swap(default_value< T > &lhs, default_value< T > &rhs) noexcept(noexcept(lhs.swap(rhs)))
Swap the content of two default_values lhs and rhs.
Definition: default_value.hpp:232
std::istream & operator>>(std::istream &in, backend_type &backend)
Use the input-stream in to initialize the backend type.
constexpr bool operator<=(const default_value< T > &lhs, const default_value< T > &rhs) noexcept
Compares the two active values: lhs <= rhs.
Definition: default_value.hpp:350
constexpr bool operator<(const default_value< T > &lhs, const default_value< T > &rhs) noexcept
Compares the two active values: lhs < rhs.
Definition: default_value.hpp:296
constexpr bool operator>(const default_value< T > &lhs, const default_value< T > &rhs) noexcept
Compares the two active values: lhs > rhs.
Definition: default_value.hpp:322
std::ostream & operator<<(std::ostream &out, backend_type backend)
Output the backend to the given output-stream out.
constexpr bool operator!=(const default_value< T > &lhs, const default_value< T > &rhs) noexcept
Compares the two active values lhs and rhs for inequality.
Definition: default_value.hpp:270
constexpr bool operator>=(const default_value< T > &lhs, const default_value< T > &rhs) noexcept
Compares the two active values: lhs >= rhs.
Definition: default_value.hpp:376
constexpr bool operator==(const default_value< T > &lhs, const default_value< T > &rhs) noexcept
Compares the two active values lhs and rhs for equality.
Definition: default_value.hpp:244
This class denotes an explicit default value initialization used to distinguish between the default v...
Definition: default_value.hpp:37
constexpr default_init() noexcept(std::is_nothrow_default_constructible_v< T >)=default
Default construct the default initialization value.
T value
The explicit default initialization value.
Definition: default_value.hpp:50
Test whether the given type T is of type plssvm::default_value ignoring all top-level const,...
Definition: default_value.hpp:420
std::size_t operator()(const plssvm::default_value< T > &val) const noexcept
Overload the function call operator for a default_value.
Definition: default_value.hpp:443
Defines some generic type traits used in the PLSSVM library.