sparrow 2.4.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Loading...
Searching...
No Matches
sparrow::value_ptr< T > Class Template Reference

A value_ptr is a smart pointer that behaves like a value. More...

#include <memory.hpp>

Public Types

using self_type = value_ptr<T>
using pointer = typename internal_pointer::pointer
using element_type = typename internal_pointer::element_type

Public Member Functions

constexpr value_ptr () noexcept=default
constexpr value_ptr (std::nullptr_t) noexcept
 Smart pointer behaving like a copiable std::unique_ptr.
constexpr value_ptr (T value)
constexpr value_ptr (T *value)
 ~value_ptr ()=default
constexpr value_ptr (const value_ptr &other)
constexpr value_ptr (value_ptr &&other) noexcept=default
constexpr value_ptroperator= (const value_ptr &other)
constexpr value_ptroperator= (value_ptr &&other) noexcept=default
constexpr value_ptroperator= (std::nullptr_t) noexcept
constexpr void reset () noexcept
constexpr T * get () noexcept
constexpr const T * get () const noexcept
constexpr operator bool () const noexcept
constexpr bool has_value () const noexcept
constexpr T & operator* ()
constexpr const T & operator* () const
constexpr T * operator-> ()
constexpr const T * operator-> () const

Detailed Description

template<class T>
class sparrow::value_ptr< T >

A value_ptr is a smart pointer that behaves like a value.

It manages the lifetime of an object of type T which is not stored in the value_ptr but a pointer, similar to unique_ptr. When copied, it copies the managed object.

Template Parameters
TThe type of the object managed by the value_ptr.

Definition at line 35 of file memory.hpp.

Member Typedef Documentation

◆ element_type

template<class T>
using sparrow::value_ptr< T >::element_type = typename internal_pointer::element_type

Definition at line 43 of file memory.hpp.

◆ pointer

template<class T>
using sparrow::value_ptr< T >::pointer = typename internal_pointer::pointer

Definition at line 42 of file memory.hpp.

◆ self_type

template<class T>
using sparrow::value_ptr< T >::self_type = value_ptr<T>

Definition at line 41 of file memory.hpp.

Constructor & Destructor Documentation

◆ value_ptr() [1/6]

template<class T>
sparrow::value_ptr< T >::value_ptr ( )
constexprdefaultnoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ value_ptr() [2/6]

template<class T>
sparrow::value_ptr< T >::value_ptr ( std::nullptr_t )
constexprnoexcept

Smart pointer behaving like a copiable std::unique_ptr.

cloning_ptr owns and manages another object through a pointer, like std::unique_ptr. The difference with std::unique_ptr is that cloning_ptrcalls the clone method of the managed object upon copy. Therefore, cloning_ptr is meant to be used with hierarchies of classes which provide a clone` method which returns a unique pointer.

Template Parameters
TThe type of the object managed by the cloning_ptr. It must satisfy the clonable concept. */ template <clonable T> class cloning_ptr { using internal_pointer = std::unique_ptr<T>;

public:

using self_type = cloning_ptr<T>; using pointer = typename internal_pointer::pointer; using element_type = typename internal_pointer::element_type;

Value semantic

constexpr cloning_ptr() noexcept = default; constexpr cloning_ptr(std::nullptr_t) noexcept; explicit constexpr cloning_ptr(pointer p) noexcept;

constexpr ~cloning_ptr() = default;

constexpr cloning_ptr(const self_type& rhs) noexcept; constexpr cloning_ptr(self_type&& rhs) noexcept = default;

template <clonable U> requires std::convertible_to<U*, T*> constexpr cloning_ptr(const cloning_ptr<U>& rhs) noexcept;

template <clonable U> requires std::convertible_to<U*, T*> constexpr cloning_ptr(cloning_ptr<U>&& rhs) noexcept;

constexpr self_type& operator=(const self_type&) noexcept; constexpr self_type& operator=(self_type&&) noexcept = default; constexpr self_type& operator=(std::nullptr_t) noexcept;

template <clonable U> requires std::convertible_to<U*, T*> constexpr self_type& operator=(const cloning_ptr<U>& rhs) noexcept;

template <clonable U> requires std::convertible_to<U*, T*> constexpr self_type& operator=(cloning_ptr<U>&& rhs) noexcept;

Modifiers

constexpr pointer release() noexcept; constexpr void reset(pointer ptr = pointer()) noexcept; void swap(self_type&) noexcept;

Observers

[[nodiscard]] constexpr pointer get() const noexcept;

constexpr explicit operator bool() const noexcept;

[[nodiscard]] constexpr std::add_lvalue_reference_t<T> operator*() const noexcept(noexcept(*std::declval<pointer>()));

[[nodiscard]] constexpr pointer operator->() const noexcept;

private:

[[nodiscard]] constexpr internal_pointer& ptr_impl() noexcept; [[nodiscard]] constexpr const internal_pointer& ptr_impl() const noexcept;

internal_pointer m_data; };

template <class T> void swap(cloning_ptr<T>& lhs, cloning_ptr<T>& rhs) noexcept;

template <class T1, class T2> requires std::equality_comparable_with<typename cloning_ptr<T1>::pointer, typename cloning_ptr<T2>::pointer> constexpr bool operator==(const cloning_ptr<T1>& lhs, const cloning_ptr<T2>& rhs) noexcept;

template <class T1, class T2> requires std::three_way_comparable_with<typename cloning_ptr<T1>::pointer, typename cloning_ptr<T2>::pointer> constexpr std::compare_three_way_result_t<typename cloning_ptr<T1>::pointer, typename cloning_ptr<T2>::pointer> operator<=>(const cloning_ptr<T1>& lhs, const cloning_ptr<T2>& rhs) noexcept;

template <class T> constexpr bool operator==(const cloning_ptr<T>& lhs, std::nullptr_t) noexcept;

template <class T> requires std::three_way_comparable<typename cloning_ptr<T>::pointer> constexpr std::compare_three_way_result_t<typename cloning_ptr<T>::pointer> operator<=>(const cloning_ptr<T>& lhs, std::nullptr_t) noexcept;

template <class T, class... Args> cloning_ptr<T> make_cloning_ptr(Args&&... args);

/**************************** value_ptr implementation *

Definition at line 220 of file memory.hpp.

◆ value_ptr() [3/6]

template<class T>
sparrow::value_ptr< T >::value_ptr ( T value)
explicitconstexpr

Definition at line 225 of file memory.hpp.

◆ value_ptr() [4/6]

template<class T>
sparrow::value_ptr< T >::value_ptr ( T * value)
explicitconstexpr

Definition at line 231 of file memory.hpp.

◆ ~value_ptr()

template<class T>
sparrow::value_ptr< T >::~value_ptr ( )
default
Here is the call graph for this function:

◆ value_ptr() [5/6]

template<class T>
sparrow::value_ptr< T >::value_ptr ( const value_ptr< T > & other)
constexpr

Definition at line 237 of file memory.hpp.

Here is the call graph for this function:

◆ value_ptr() [6/6]

template<class T>
sparrow::value_ptr< T >::value_ptr ( value_ptr< T > && other)
constexprdefaultnoexcept
Here is the call graph for this function:

Member Function Documentation

◆ get() [1/2]

template<class T>
const T * sparrow::value_ptr< T >::get ( ) const
nodiscardconstexprnoexcept

Definition at line 283 of file memory.hpp.

◆ get() [2/2]

template<class T>
T * sparrow::value_ptr< T >::get ( )
nodiscardconstexprnoexcept

Definition at line 277 of file memory.hpp.

Here is the caller graph for this function:

◆ has_value()

template<class T>
bool sparrow::value_ptr< T >::has_value ( ) const
nodiscardconstexprnoexcept

Definition at line 295 of file memory.hpp.

Here is the caller graph for this function:

◆ operator bool()

template<class T>
sparrow::value_ptr< T >::operator bool ( ) const
explicitconstexprnoexcept

Definition at line 289 of file memory.hpp.

Here is the call graph for this function:

◆ operator*() [1/2]

template<class T>
T & sparrow::value_ptr< T >::operator* ( )
nodiscardconstexpr

Definition at line 301 of file memory.hpp.

◆ operator*() [2/2]

template<class T>
const T & sparrow::value_ptr< T >::operator* ( ) const
nodiscardconstexpr

Definition at line 308 of file memory.hpp.

◆ operator->() [1/2]

template<class T>
T * sparrow::value_ptr< T >::operator-> ( )
nodiscardconstexpr

Definition at line 315 of file memory.hpp.

◆ operator->() [2/2]

template<class T>
const T * sparrow::value_ptr< T >::operator-> ( ) const
nodiscardconstexpr

Definition at line 322 of file memory.hpp.

◆ operator=() [1/3]

template<class T>
value_ptr< T > & sparrow::value_ptr< T >::operator= ( const value_ptr< T > & other)
constexpr

Definition at line 243 of file memory.hpp.

Here is the call graph for this function:

◆ operator=() [2/3]

template<class T>
value_ptr< T > & sparrow::value_ptr< T >::operator= ( std::nullptr_t )
constexprnoexcept

Definition at line 264 of file memory.hpp.

Here is the call graph for this function:

◆ operator=() [3/3]

template<class T>
value_ptr & sparrow::value_ptr< T >::operator= ( value_ptr< T > && other)
constexprdefaultnoexcept
Here is the call graph for this function:

◆ reset()

template<class T>
void sparrow::value_ptr< T >::reset ( )
constexprnoexcept

Definition at line 271 of file memory.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: