TPIE

11a2c2d
array.h File Reference
#include <tpie/util.h>
#include <boost/iterator/iterator_facade.hpp>
#include <tpie/memory.h>
#include <tpie/array_view_base.h>
#include <type_traits>
#include <cassert>
#include <ostream>

Go to the source code of this file.

Classes

class  tpie::array_iter_base< TT, forward >
 Shared implementation of array iterators. More...
 
struct  tpie::trivial_same_size< C >
 
struct  tpie::bits::allocator_usage< T, Allocator >
 
class  tpie::array< T, Allocator >
 A generic array with a fixed size. More...
 
struct  tpie::bits::allocator_usage< T, allocator< T > >
 
struct  tpie::bits::allocator_usage< T, Allocator >
 

Namespaces

 tpie
 

Functions

template<typename T >
std::ostream & tpie::operator<< (std::ostream &o, const array< T > &a)
 
template<typename T >
void std::swap (tpie::array< T > &a, tpie::array< T > &b)
 Enable std::swapping two tpie::arrays. More...
 
template<typename TT1 , bool forward1, typename TT2 , bool forward2>
tpie::array_iter_base< TT2, forward2 > std::copy (tpie::array_iter_base< TT1, forward1 > first, tpie::array_iter_base< TT1, forward1 > last, tpie::array_iter_base< TT2, forward2 > d_first)
 std::copy template specialization for tpie::array. More...
 
template<typename TT , bool forward, typename OutputIterator >
OutputIterator std::copy (tpie::array_iter_base< TT, forward > first, tpie::array_iter_base< TT, forward > last, OutputIterator d_first)
 std::copy template specialization for tpie::array as input. More...
 
template<typename TT , bool forward, typename InputIterator >
tpie::array_iter_base< TT, forward > std::copy (InputIterator first, InputIterator last, tpie::array_iter_base< TT, forward > d_first)
 std::copy template specialization for tpie::array as output. More...
 

Detailed Description

Generic internal array with known memory requirements.

Definition in file array.h.

Function Documentation

◆ copy() [1/3]

template<typename TT , bool forward, typename InputIterator >
tpie::array_iter_base<TT, forward> std::copy ( InputIterator  first,
InputIterator  last,
tpie::array_iter_base< TT, forward >  d_first 
)

std::copy template specialization for tpie::array as output.

Definition at line 743 of file array.h.

745  {
746 
747  ptrdiff_t dist = copy(first, last, &*d_first) - &*d_first;
748  return d_first + dist;
749 }

References std::copy().

◆ copy() [2/3]

template<typename TT , bool forward, typename OutputIterator >
OutputIterator std::copy ( tpie::array_iter_base< TT, forward >  first,
tpie::array_iter_base< TT, forward >  last,
OutputIterator  d_first 
)

std::copy template specialization for tpie::array as input.

Definition at line 731 of file array.h.

733  {
734 
735  return copy(&*first, &*last, d_first);
736 }

References std::copy().

◆ copy() [3/3]

template<typename TT1 , bool forward1, typename TT2 , bool forward2>
tpie::array_iter_base<TT2, forward2> std::copy ( tpie::array_iter_base< TT1, forward1 >  first,
tpie::array_iter_base< TT1, forward1 >  last,
tpie::array_iter_base< TT2, forward2 >  d_first 
)

std::copy template specialization for tpie::array.

Definition at line 718 of file array.h.

720  {
721 
722  ptrdiff_t dist = copy(&*first, &*last, &*d_first) - &*d_first;
723  return d_first + dist;
724 }

References std::copy().

Referenced by std::copy().

◆ swap()

template<typename T >
void std::swap ( tpie::array< T > &  a,
tpie::array< T > &  b 
)

Enable std::swapping two tpie::arrays.

Citing the C++11 draft N3242, dated 2011-02-28, 17.6.4.2.1, paragraph 1:

"The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std unless otherwise specified. A program may add a template specialization for any standard library template to namespace std only if the declaration depends on a user-defined type and the specialization meets the standard library requirements for the original template and is not explicitly prohibited." [Footnote: "Any library code that instantiates other library templates must be prepared to work adequately with any user-supplied specialization that meets the minimum requirements of the Standard."]

In other words, we are allowed to specialize std::swap.

Definition at line 709 of file array.h.

709  {
710  a.swap(b);
711 }

References tpie::array< T, Allocator >::swap(), and std::swap().

Referenced by std::swap().

std::copy
tpie::array_iter_base< TT2, forward2 > copy(tpie::array_iter_base< TT1, forward1 > first, tpie::array_iter_base< TT1, forward1 > last, tpie::array_iter_base< TT2, forward2 > d_first)
std::copy template specialization for tpie::array.
Definition: array.h:718
tpie::array::swap
void swap(array &other)
Swap two arrays.
Definition: array.h:504