Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/t8_types/t8_type.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* This class template allows the creation of a type that can be extended with
* multiple competences. Each competence is a template class that takes the
* main type as a template parameter.
*
*
* This is heavily inspired by (and taken from) https://www.fluentcpp.com/2016/12/08/strong-types-for-strong-interfaces/
*
* \tparam T The type of the value to be stored.
Expand All @@ -59,16 +59,14 @@ class T8Type: public competence<T8Type<T, Parameter, competence...>>... {

/**
* Construct a new T8Type object
*
* \tparam T_ref
* \param value
*
* \note This constructor is only enabled if T is not a reference.
*
* \param value
*
* \note This constructor is only enabled if T is not a reference value.
*/
template <typename T_ref = T>
explicit constexpr T8Type (T&& value,
typename std::enable_if<!std::is_reference<T_ref> {}, std::nullptr_t>::type = nullptr)
: value_ (std::move (value))
explicit constexpr T8Type (T&& value)
requires (!std::is_reference_v<T>)
: value_ (std::forward<T> (value))
{
}

Expand Down Expand Up @@ -99,13 +97,13 @@ class T8Type: public competence<T8Type<T, Parameter, competence...>>... {
constexpr T const&
get () const noexcept
{
return std::move (value_);
return value_;
}

/** Implicit conversion to value type
* to cast a variable instance of this class into its
* value_type for example for printing.
*
*
* \note to future devs: If this causes trouble in the future when we create a
* type that is not easily (or should not be) convertible to its base type,
* we can wrap this inside an enable_if condition and only allow the conversion
Expand Down