Templatious
 All Classes Functions Pages
Static Public Member Functions | List of all members
templatious::StaticAdapter Struct Reference

#include <StaticAdapter.hpp>

Static Public Member Functions

template<class T >
static auto begin (T &&c) -> decltype(adapters::CollectionAdapter< T >::begin(c))
 
template<class T >
static auto end (T &&c) -> decltype(adapters::CollectionAdapter< T >::end(c))
 
template<class T >
static auto cbegin (const T &c) -> typename adapters::CollectionAdapter< T >::ConstIterator
 
template<class T >
static auto cend (const T &c) -> typename adapters::CollectionAdapter< T >::ConstIterator
 
template<class T , class U >
static void add (T &c, const std::initializer_list< U > &o)
 
template<class T , class U >
static void add (T &c, U &&o)
 
template<class T , class U , class... Args>
static void add (T &c, U &&o, Args &&...args)
 
template<class T , class F , class U >
static void addCustom (T &c, F &&f, U &&o)
 
template<class T , class F , class U , class... Args>
static void addCustom (T &c, F &&f, U &&o, Args &&...args)
 
template<class T >
static long size (const T &c)
 
template<class T >
static long trueSize (const T &c)
 
template<class T >
static bool canAdd (const T &c)
 
template<class T >
static auto getByIndex (T &c, long i) -> typename adapters::CollectionAdapter< T >::ValueType &
 
template<class T >
static void erase (T &c, typename adapters::CollectionAdapter< T >::Iterator beg, typename adapters::CollectionAdapter< T >::Iterator end)
 
template<class T >
static void erase (T &c, typename adapters::CollectionAdapter< T >::Iterator pos)
 
template<class T >
static void eraseTillEnd (T &c, typename adapters::CollectionAdapter< T >::Iterator pos)
 
template<class T >
static auto iterAt (T &c, long i) -> typename adapters::CollectionAdapter< T >::Iterator
 
template<class T >
static auto citerAt (T &c, long i) -> typename adapters::CollectionAdapter< T >::ConstIterator
 
template<class T , class V >
static void insert (T &c, typename adapters::CollectionAdapter< T >::Iterator at, V &&val)
 
template<class T >
static void clear (T &&c)
 
template<class T , class... Tail>
static void clear (T &&c, Tail &&...t)
 
template<class T >
static auto vbegin (T &c) -> VIterator< typename adapters::CollectionAdapter< T >::ValueType >
 
template<class T >
static auto vend (T &c) -> VIterator< typename adapters::CollectionAdapter< T >::ValueType >
 
template<class T >
static auto vcbegin (const T &c) -> VIterator< typename adapters::CollectionAdapter< T >::ConstValueType >
 
template<class T >
static auto vcend (const T &c) -> VIterator< typename adapters::CollectionAdapter< T >::ConstValueType >
 
template<class T >
static auto viterAt (T &c, long s) -> VIterator< typename adapters::CollectionAdapter< T >::ValueType >
 
template<class T >
static auto vciterAt (const T &c, long s) -> VIterator< typename adapters::CollectionAdapter< T >::ConstValueType >
 

Detailed Description

A class which holds static methods that mainly have to do with interacting with a single collection.

Member Function Documentation

template<class T , class U >
static void templatious::StaticAdapter::add ( T &  c,
const std::initializer_list< U > &  o 
)
inlinestatic

Adds element to any collection with initializer list.

Parameters
[in,out]cCollection to be added to.
[in]oInitializer list.

Example:

std::vector<int> v;
SA::add(v,{1,2,3,4});
template<class T , class U >
static void templatious::StaticAdapter::add ( T &  c,
U &&  o 
)
inlinestatic

Adds packs/elements/collections to any collection.

Parameters
[in,out]cCollection to be added to.
[in]oValue to be added. Can be pack, collection or a simple variable. Individual elements in packs or collections are added.

Example:

std::vector<int> v;
auto p = SF::pack(1,2,3);
SA::add(v,p,4,5,SF::seqL(6,8));
// v now contains {1,2,3,4,5,6,7}
template<class T , class U , class... Args>
static void templatious::StaticAdapter::add ( T &  c,
U &&  o,
Args &&...  args 
)
inlinestatic

Variadic add method overload.

Parameters
[in,out]cCollection to be added to.
[in]oValue to be added. Can be pack, collection or a simple variable. Individual elements in packs or collections are added.
[in]argsThe rest of the values to be processed.

Example:

std::vector<int> v;
auto p = SF::pack(1,2,3);
SA::add(v,p,4,5,SF::seqL(6,8));
// v now contains {1,2,3,4,5,6,7}
template<class T , class F , class U >
static void templatious::StaticAdapter::addCustom ( T &  c,
F &&  f,
U &&  o 
)
inlinestatic

Custom add function.

Parameters
[in,out]cCollection to be added to.
[in]fFunction to be applied for each added element. Should return final addable type.
[in]oValue to be added. Can be pack, collection or a simple variable. Individual elements in packs or collections are added.

Example:

struct SomePod {
SomePod() : _num(7) {}
int _num;
};
SomePod p;
std::vector<int> v;
SA::addCustom(v,[](const SomePod& p) {
return p._num;
},p,p,p);
// v now contains {7,7,7}
template<class T , class F , class U , class... Args>
static void templatious::StaticAdapter::addCustom ( T &  c,
F &&  f,
U &&  o,
Args &&...  args 
)
inlinestatic

Custom add function.

Parameters
[in,out]cCollection to be added to.
[in]fFunction to be applied for each added element. Should return final addable type.
[in]oValue to be added. Can be pack, collection or a simple variable. Individual elements in packs or collections are added.
[in]argsThe rest of the values to be processed.

Example:

struct SomePod {
SomePod() : _num(7) {}
int _num;
};
SomePod p;
std::vector<int> v;
SA::addCustom(v,[](const SomePod& p) {
return p._num;
},p,p,p);
// v now contains {7,7,7}
template<class T >
static auto templatious::StaticAdapter::begin ( T &&  c) -> decltype(adapters::CollectionAdapter<T>::begin(c))
inlinestatic

Returns begin iterator for any collection.

Parameters
[in]cCollection
template<class T >
static bool templatious::StaticAdapter::canAdd ( const T &  c)
inlinestatic

Determines if elements could be added to collection.

Parameters
[in]cCollection to query.
template<class T >
static auto templatious::StaticAdapter::cbegin ( const T &  c) -> typename adapters::CollectionAdapter<T>::ConstIterator
inlinestatic

Returns const begin iterator for any collection.

Parameters
[in]cCollection
template<class T >
static auto templatious::StaticAdapter::cend ( const T &  c) -> typename adapters::CollectionAdapter<T>::ConstIterator
inlinestatic

Returns const end iterator for any collection.

Parameters
[in]cCollection
template<class T >
static auto templatious::StaticAdapter::citerAt ( T &  c,
long  i 
) -> typename adapters::CollectionAdapter<T>::ConstIterator
inlinestatic

Get constant iterator from a collection by index. Requesting iterator at a position of size should return end iterator. However, anything more than that throws an exception. Requesting iterator at negative position throws an exception.

Parameters
[in]cCollection to get iterator from.
[in]iIndex of iterator to get.

Example:

std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
assert( *SA::citerAt(v,3) == 3 );
template<class T >
static void templatious::StaticAdapter::clear ( T &&  c)
inlinestatic

Clear collection.

Parameters
[out]cCollection to clear.

Example:

std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
SA::clear(v);
// v contains {} (nothing)
template<class T , class... Tail>
static void templatious::StaticAdapter::clear ( T &&  c,
Tail &&...  t 
)
inlinestatic

Clear multiple collections.

Parameters
[out]cCollection to clear.
[out]tRest of collections to clear.

Example:

std::vector<int> v1;
std::vector<int> v2;
SA::add(v1,SF::seqL(7));
SA::add(v2,v1);
// v1 and v2 contains {0,1,2,3,4,5,6}
SA::clear(v1,v2);
// v1 and v2 contains {} (nothing)
template<class T >
static auto templatious::StaticAdapter::end ( T &&  c) -> decltype(adapters::CollectionAdapter<T>::end(c))
inlinestatic

Returns end iterator for any collection.

Parameters
[in]cCollection
template<class T >
static void templatious::StaticAdapter::erase ( T &  c,
typename adapters::CollectionAdapter< T >::Iterator  beg,
typename adapters::CollectionAdapter< T >::Iterator  end 
)
inlinestatic

Erase elements from collection by beginning and end iterators.

Parameters
[in,out]cCollection to erase from.
[in]begBeginning iterator.
[in]endEnd iterator.

Example:

std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
SA::erase(v,SA::begin(v),SA::iterAt(v,3));
// v contains {3,4,5,6}
template<class T >
static void templatious::StaticAdapter::erase ( T &  c,
typename adapters::CollectionAdapter< T >::Iterator  pos 
)
inlinestatic

Erase single element from a collection.

Parameters
[in,out]cCollection to erase from.
[in]posIterator to erase.

Example:

std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
SA::erase(v,SA::begin(v));
// v contains {1,2,3,4,5,6}
template<class T >
static void templatious::StaticAdapter::eraseTillEnd ( T &  c,
typename adapters::CollectionAdapter< T >::Iterator  pos 
)
inlinestatic

Erase elements from a collection from position until end.

Parameters
[in,out]cCollection to erase from.
[in]posIterator to start erasing from.

Example:

std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
SA::eraseTillEnd(v,SA::iterAt(v,3));
// v contains {0,1,2}
template<class T >
static auto templatious::StaticAdapter::getByIndex ( T &  c,
long  i 
) -> typename adapters::CollectionAdapter<T>::ValueType&
inlinestatic

Get element from collection by index. Throws if out of bounds.

Parameters
[in,out]cCollection to get element from.
[in]iElement index to get.

Example:

std::vector<int> v;
SA::add(v,7);
assert( SA::getByIndex(v,0) == 7 );
template<class T , class V >
static void templatious::StaticAdapter::insert ( T &  c,
typename adapters::CollectionAdapter< T >::Iterator  at,
V &&  val 
)
inlinestatic

Insert element to collection.

Parameters
[in,out]cCollection to insert to.
[in]atPosition iterator where to insert. Inserted element replaces element pointed to this iterator.
[in]valValue to insert.

Example:

std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
SA::insert(v,SA::iterAt(v,3),10);
// v contains {0,1,2,10,3,4,5,6}
template<class T >
static auto templatious::StaticAdapter::iterAt ( T &  c,
long  i 
) -> typename adapters::CollectionAdapter<T>::Iterator
inlinestatic

Get iterator from a collection by index. Requesting iterator at a position of size should return end iterator. However, anything more than that throws an exception. Requesting iterator at negative position throws an exception.

Parameters
[in]cCollection to get iterator from.
[in]iIndex of iterator to get.

Example:

std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
assert( *SA::iterAt(v,3) == 3 );
template<class T >
static long templatious::StaticAdapter::size ( const T &  c)
inlinestatic

Size getter for collection. Returns size or -1 if size cannot be determined.

Parameters
[in]cCollection to lookup size for.
template<class T >
static long templatious::StaticAdapter::trueSize ( const T &  c)
inlinestatic

Size getter for collection. Returns what would simple size function return, but if simple size function returns -1 collection is traversed to find it's final size.

Parameters
[in]cCollection to lookup size for.
template<class T >
static auto templatious::StaticAdapter::vbegin ( T &  c) -> VIterator< typename adapters::CollectionAdapter<T>::ValueType >
inlinestatic

Virtual begin iterator. Can be used for exposing elements across translation units and hiding true type signature of the iterator.

Parameters
[in,out]cCollection to expose.

Example:

void someFunc(VIter& b,VIter& e) {
while (b != e) {
std::cout << *b << " ";
++b;
}
std::cout << std::endl;
}
...
std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
auto b = SA::vbegin(v);
auto e = SA::vend(v);
someFunc(b,e);
// prints out:
// 0 1 2 3 4 5 6
template<class T >
static auto templatious::StaticAdapter::vcbegin ( const T &  c) -> VIterator< typename adapters::CollectionAdapter<T>::ConstValueType >
inlinestatic

Virtual const begin iterator. Can be used for exposing elements across translation units and hiding the true type of the iterator.

Parameters
[in,out]cCollection to expose.

Example:

void someFunc(VIter& b,VIter& e) {
while (b != e) {
std::cout << *b << " ";
++b;
}
std::cout << std::endl;
}
...
std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
auto b = SA::vcbegin(v);
auto e = SA::vcend(v);
someFunc(b,e);
// prints out:
// 0 1 2 3 4 5 6
template<class T >
static auto templatious::StaticAdapter::vcend ( const T &  c) -> VIterator< typename adapters::CollectionAdapter<T>::ConstValueType >
inlinestatic

Virtual const end iterator. Can be used for exposing elements across translation units.

Parameters
[in,out]cCollection to expose.

Example:

void someFunc(VIter& b,VIter& e) {
while (b != e) {
std::cout << *b << " ";
++b;
}
std::cout << std::endl;
}
...
std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
auto b = SA::vcbegin(v);
auto e = SA::vcend(v);
someFunc(b,e);
// prints out:
// 0 1 2 3 4 5 6
template<class T >
static auto templatious::StaticAdapter::vciterAt ( const T &  c,
long  s 
) -> VIterator< typename adapters::CollectionAdapter<T>::ConstValueType >
inlinestatic

Virtual const iterator by index. Can be used for exposing elements across translation units.

Parameters
[in,out]cCollection to expose.

Example:

void someFunc(VIter& b,VIter& e) {
while (b != e) {
std::cout << *b << " ";
++b;
}
std::cout << std::endl;
}
...
std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
auto b = SA::vciterAt(v,3);
auto e = SA::vcend(v);
someFunc(b,e);
// prints out:
// 3 4 5 6
template<class T >
static auto templatious::StaticAdapter::vend ( T &  c) -> VIterator< typename adapters::CollectionAdapter<T>::ValueType >
inlinestatic

Virtual end iterator. Can be used for exposing elements across translation units and hiding true type signature of the iterator.

Parameters
[in,out]cCollection to expose.

Example:

void someFunc(VIter& b,VIter& e) {
while (b != e) {
std::cout << *b << " ";
++b;
}
std::cout << std::endl;
}
...
std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
auto b = SA::vbegin(v);
auto e = SA::vend(v);
someFunc(b,e);
// prints out:
// 0 1 2 3 4 5 6
template<class T >
static auto templatious::StaticAdapter::viterAt ( T &  c,
long  s 
) -> VIterator< typename adapters::CollectionAdapter<T>::ValueType >
inlinestatic

Virtual iterator by index. Can be used for exposing elements across translation units and hiding the true type of the collection iterator.

Parameters
[in,out]cCollection to expose.

Example:

void someFunc(VIter& b,VIter& e) {
while (b != e) {
std::cout << *b << " ";
++b;
}
std::cout << std::endl;
}
...
std::vector<int> v;
SA::add(v,SF::seqL(7));
// v contains {0,1,2,3,4,5,6}
auto b = SA::viterAt(v,3);
auto e = SA::vend(v);
someFunc(b,e);
// prints out:
// 3 4 5 6

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