Commit 1ab17769 authored by Jan Koniarik's avatar Jan Koniarik
Browse files

delaundered

parent ceb7540c
Pipeline #101514 passed with stage
in 16 seconds
......@@ -207,8 +207,6 @@ private:
// private methods
// --------------------------------------------------------------------------------
// To understand std::launder:
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0532r0.pdf
//
// Set of [delete,init,emplace]_item methods is necessary as data_ is not array of T, but
// array of byte-like-type that can store T -> T does not have to be initialized there. We
......@@ -232,15 +230,14 @@ private:
::new ( gen_ptr ) T( std::forward< Args >( args )... );
}
// Reference to the item in data_storage. std::launder is necessary here per the paper
// linked above.
// Reference to the item in data_storage.
[[nodiscard]] reference ref_item( size_type i )
{
return *std::launder( reinterpret_cast< T* >( &data_[i] ) );
return *reinterpret_cast< T* >( &data_[i] );
}
[[nodiscard]] const_reference ref_item( size_type i ) const
{
return *std::launder( reinterpret_cast< const T* >( &data_[i] ) );
return *reinterpret_cast< const T* >( &data_[i] );
}
// Cleans entire buffer from items.
......
......@@ -189,11 +189,11 @@ private:
// Reference to the item in data_storage.
[[nodiscard]] reference ref_item( size_type i )
{
return *std::launder( reinterpret_cast< T* >( &data_[i] ) );
return *reinterpret_cast< T* >( &data_[i] );
}
[[nodiscard]] const_reference ref_item( size_type i ) const
{
return *std::launder( reinterpret_cast< const T* >( &data_[i] ) );
return *reinterpret_cast< const T* >( &data_[i] );
}
// Cleans entire buffer from items.
......@@ -274,11 +274,11 @@ class static_vector_iterator : public generic_iterator< static_vector_iterator<
public:
T& operator*()
{
return *std::launder( reinterpret_cast< T* >( raw_ptr_ ) );
return *reinterpret_cast< T* >( raw_ptr_ );
}
const T& operator*() const
{
return *std::launder( reinterpret_cast< const T* >( raw_ptr_ ) );
return *reinterpret_cast< const T* >( raw_ptr_ );
}
static_vector_iterator& operator+=( std::ptrdiff_t offset )
......@@ -326,11 +326,11 @@ class const_static_vector_iterator : public generic_iterator< const_static_vecto
public:
const T& operator*()
{
return *std::launder( reinterpret_cast< const T* >( raw_ptr_ ) );
return *reinterpret_cast< const T* >( raw_ptr_ );
}
const T& operator*() const
{
return *std::launder( reinterpret_cast< const T* >( raw_ptr_ ) );
return *reinterpret_cast< const T* >( raw_ptr_ );
}
const_static_vector_iterator& operator+=( std::ptrdiff_t offset )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment