Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
SpecialCtors< Container, T > Struct Template Reference

Special constructors common to Aleph-w ( \(\aleph_\omega\)) containers. More...

#include <ah-dry.H>

Inheritance diagram for SpecialCtors< Container, T >:
[legend]

Public Member Functions

 SpecialCtors ()=default
 Default constructor; it appends nothing.
 
 SpecialCtors (const SpecialCtors &)=default
 Copy constructor; the derived container copies its items.
 
 SpecialCtors (SpecialCtors &&) noexcept
 Move constructor; the derived container moves its items.
 
SpecialCtors & operator= (const SpecialCtors &)=default
 Copy assignment; the derived container copies its items.
 
SpecialCtors & operator= (SpecialCtors &&) noexcept
 Move assignment; the derived container moves its items.
 
 SpecialCtors (const Aleph::DynList< T > &l)
 Build the container by inserting all items of the list l.
 
template<class It >
requires (not std::is_arithmetic_v<It> and requires(It it) { *it; ++it; it != it; })
 SpecialCtors (It b, It e)
 Construct the container from a range of iterators.
 
 SpecialCtors (std::initializer_list< T > l)
 Construct the container from an initializer list.
 

Private Member Functions

void free_appended () noexcept
 Free the items that a constructor of this base appended.
 
template<class Fill >
void build_apart (Fill fill)
 Fill the container: in another one built apart, whose items it takes with swap(), if the container has a default constructor and swap(); if not, in place, freeing with free_appended() what was appended if fill throws.
 

Detailed Description

template<class Container, typename T>
struct SpecialCtors< Container, T >

Special constructors common to Aleph-w ( \(\aleph_\omega\)) containers.

Basically, the constructors of this class append a sequence of items.

Warning
Note that these constructors require that the class is correctly initialized, which not only very often is not the case, but it could be impossible in most cases. The most part of situations, the derived class must be initialized before to start to append new items. But this is not the case during this construction. So, don't use this class unless you are absolutely sure that the derived class has been initialized.

Definition at line 1099 of file ah-dry.H.

Constructor & Destructor Documentation

◆ SpecialCtors() [1/6]

template<class Container , typename T >
SpecialCtors< Container, T >::SpecialCtors ( )
default

Default constructor; it appends nothing.

◆ SpecialCtors() [2/6]

template<class Container , typename T >
SpecialCtors< Container, T >::SpecialCtors ( const SpecialCtors< Container, T > &  )
default

Copy constructor; the derived container copies its items.

◆ SpecialCtors() [3/6]

template<class Container , typename T >
SpecialCtors< Container, T >::SpecialCtors ( SpecialCtors< Container, T > &&  )
inlinenoexcept

Move constructor; the derived container moves its items.

Definition at line 1108 of file ah-dry.H.

◆ SpecialCtors() [4/6]

template<class Container , typename T >
SpecialCtors< Container, T >::SpecialCtors ( const Aleph::DynList< T > &  l)
inline

Build the container by inserting all items of the list l.

Parameters
[in]llist of items to insert
Exceptions
bad_allocif there is no enough memory, or what the copy of an item throws. Then the items already appended are freed, if the container has empty(): its destructor does not run.

Definition at line 1128 of file ah-dry.H.

References SpecialCtors< Container, T >::build_apart(), FunctionalMethods< Container, T >::for_each(), and l.

◆ SpecialCtors() [5/6]

template<class Container , typename T >
template<class It >
requires (not std::is_arithmetic_v<It> and requires(It it) { *it; ++it; it != it; })
SpecialCtors< Container, T >::SpecialCtors ( It  b,
It  e 
)
inline

Construct the container from a range of iterators.

It must behave as an iterator: an arithmetic type, as in DynList<int> l(3, 7), does not select this constructor.

Parameters
[in]bbegin iterator
[in]eend iterator
Exceptions
bad_allocif there is no enough memory, or what the iterators or the copy of an item throw. Then the items already appended are freed, if the container has empty().

Definition at line 1150 of file ah-dry.H.

References SpecialCtors< Container, T >::build_apart().

◆ SpecialCtors() [6/6]

template<class Container , typename T >
SpecialCtors< Container, T >::SpecialCtors ( std::initializer_list< T >  l)
inline

Construct the container from an initializer list.

Parameters
[in]linitializer list of items
Exceptions
bad_allocif there is no enough memory, or what the copy of an item throws. Then the items already appended are freed, if the container has empty().

Definition at line 1166 of file ah-dry.H.

References SpecialCtors< Container, T >::build_apart(), and l.

Member Function Documentation

◆ build_apart()

template<class Container , typename T >
template<class Fill >
void SpecialCtors< Container, T >::build_apart ( Fill  fill)
inlineprivate

Fill the container: in another one built apart, whose items it takes with swap(), if the container has a default constructor and swap(); if not, in place, freeing with free_appended() what was appended if fill throws.

Built apart, the destructor of the other container frees what it took if fill throws, and the copy costs less than in place, where the container being built must be ready for the cleanup at each append.

Definition at line 1199 of file ah-dry.H.

References fill(), SpecialCtors< Container, T >::free_appended(), and swap().

Referenced by SpecialCtors< Container, T >::SpecialCtors(), SpecialCtors< Container, T >::SpecialCtors(), and SpecialCtors< Container, T >::SpecialCtors().

◆ free_appended()

template<class Container , typename T >
void SpecialCtors< Container, T >::free_appended ( )
inlineprivatenoexcept

Free the items that a constructor of this base appended.

When such a constructor throws, the container is not built and its destructor does not run: without this, the items would leak with their nodes. A container without empty() keeps them.

Definition at line 1182 of file ah-dry.H.

Referenced by SpecialCtors< Container, T >::build_apart().

◆ operator=() [1/2]

template<class Container , typename T >
SpecialCtors & SpecialCtors< Container, T >::operator= ( const SpecialCtors< Container, T > &  )
default

Copy assignment; the derived container copies its items.

◆ operator=() [2/2]

template<class Container , typename T >
SpecialCtors & SpecialCtors< Container, T >::operator= ( SpecialCtors< Container, T > &&  )
inlinenoexcept

Move assignment; the derived container moves its items.

Returns
*this.

Definition at line 1116 of file ah-dry.H.


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