-
Notifications
You must be signed in to change notification settings - Fork 764
Open
Labels
Priority: LowCan be handled at leisureCan be handled at leisureStatus: In ProgressCurrently being worked onCurrently being worked onType: BugIndicates a bug or errorIndicates a bug or error
Description
gsl::not_null< T > has the following conversion operator:
constexpr operator T() const
{
return get();
}which is deleted for non-copy constructible types such as std::unique_ptr due to gsl::not_null< T >'s conditional return type mapping to const T&:
constexpr std::conditional_t<std::is_copy_constructible<T>::value, T, const T&> get() const
{
Ensures(ptr_ != nullptr);
return ptr_;
}Therefore, it is not possible to extract (the potentially expensive) ptr_ anymore for non-copy constructible types once a gsl::not_null< T > is constructed around it. Wouldn't it make sense to use ref-qualified member methods for both methods (i.e. conversion operator and get)?
// For non-copy constructible types:
constexpr operator const T&() const &
{
return ptr_;
}
constexpr operator T() &&
{
return std::move(ptr_);
}ujos
Metadata
Metadata
Assignees
Labels
Priority: LowCan be handled at leisureCan be handled at leisureStatus: In ProgressCurrently being worked onCurrently being worked onType: BugIndicates a bug or errorIndicates a bug or error
Type
Projects
Status
Assigned