12 #ifndef ECL_CONTAINERS_ARRAY_NO_MEM_CHECK_HPP_ 13 #define ECL_CONTAINERS_ARRAY_NO_MEM_CHECK_HPP_ 14 #ifndef ECL_MEM_CHECK_ARRAYS 23 #include "../definitions.hpp" 24 #include "../initialiser.hpp" 25 #include "../stencil.hpp" 26 #include <ecl/config/macros.hpp> 27 #include <ecl/concepts/macros.hpp> 28 #include <ecl/concepts/blueprints.hpp> 29 #include <ecl/concepts/streams.hpp> 30 #include <ecl/errors/compile_time_assert.hpp> 31 #include <ecl/exceptions/standard_exception.hpp> 43 namespace blueprints {
45 template <
typename Type,
size_t N>
class ArrayFactory;
46 template <
typename Derived>
class ArrayBluePrint;
47 template <
typename Type,
size_t Size>
class ConstantArray;
51 namespace formatters {
53 template <
typename Type,
size_t N>
class ArrayFormatter;
105 template<
typename Type, std::
size_t Size = DynamicStorage>
106 class ECL_PUBLIC Array :
public blueprints::ArrayFactory<Type,Size> {
111 typedef Type value_type;
112 typedef Type* iterator;
113 typedef const Type* const_iterator;
114 typedef Type& reference;
115 typedef const Type& const_reference;
116 typedef std::size_t size_type;
117 typedef std::ptrdiff_t difference_type;
118 typedef std::reverse_iterator<iterator> reverse_iterator;
119 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
120 typedef blueprints::ArrayFactory<value_type,Size> Factory;
121 typedef formatters::ArrayFormatter<Type,Size>
Formatter;
154 Array(
const blueprints::ArrayBluePrint< T > &blueprint) {
156 blueprint.implementApply(*
this);
177 containers::BoundedListInitialiser<Type,Type*,Size>
operator<<(
const Type &value) {
178 return containers::BoundedListInitialiser<value_type,iterator,Size>(value,elements);
188 iterator begin() {
return elements; }
193 const_iterator begin()
const {
return elements; }
198 iterator end() {
return elements+Size; }
203 const_iterator end()
const {
return elements+Size; }
208 reverse_iterator rbegin() {
return reverse_iterator(end()); }
213 const_reverse_iterator rbegin()
const {
return const_reverse_iterator(end()); }
218 reverse_iterator rend() {
return reverse_iterator(begin()); }
223 const_reverse_iterator rend()
const {
return const_reverse_iterator(begin()); }
232 reference front() {
return elements[0]; }
237 const_reference front()
const {
return elements[0]; }
242 reference back() {
return elements[Size-1]; }
247 const_reference back()
const {
return elements[Size-1]; }
263 Stencil< Array<Type,Size> > stencil(
const unsigned int& start_index,
const unsigned int& n)
ecl_assert_throw_decl(StandardException) {
266 return Stencil< Array<Type,Size> >(*
this, begin()+start_index, begin()+start_index+n);
307 reference at(size_type i)
throw(StandardException) {
325 const_reference at(size_type i)
const throw(StandardException) {
340 static size_type
size() {
return Size; }
352 template <
typename OutputStream,
typename ElementType,
size_t ArraySize>
353 friend OutputStream& operator<<(OutputStream &ostream , const Array<ElementType,ArraySize> &
array);
356 value_type elements[Size];
363 template <
typename OutputStream,
typename ElementType,
size_t ArraySize>
364 OutputStream& operator<<(OutputStream &ostream , const Array<ElementType,ArraySize> &
array) {
369 for(
size_t i = 0; i < ArraySize; ++i )
371 ostream <<
array[i] <<
" ";
384 namespace blueprints {
410 template <
typename Derived>
411 class ArrayBluePrint {
425 template <
typename BaseType>
426 BaseType implementInstantiate() {
427 return static_cast<Derived*
>(
this)->instantiate();
442 template <
typename BaseType>
443 void implementApply(BaseType&
array)
const {
444 static_cast<const Derived*
>(
this)->apply(array);
447 virtual ~ArrayBluePrint() {}
457 template <
typename Type,
size_t Size>
458 class ConstantArray :
public ArrayBluePrint< ConstantArray<Type, Size> > {
474 virtual ~ConstantArray() {};
486 base_type instantiate() {
488 std::fill_n(array.
begin(),Size,val);
496 void apply(base_type&
array)
const {
497 std::fill_n(array.begin(),Size,val);
512 template<
typename Type,
size_t Size>
521 static ConstantArray<Type,Size> Constant(
const Type&
value) {
522 return ConstantArray<Type,Size>(value);
525 virtual ~ArrayFactory() {};
Fixed size container with a few bells and whistles.
Defines validating functionality for the streams concept.
#define LOC
Stringify the line of code you are at.
OutputStream & operator<<(OutputStream &ostream, const Void void_object)
Output stream operator for Void objects.
#define ecl_assert_throw(expression, exception)
Debug mode throw with a logical condition check.
ecl_geometry_PUBLIC int size(const Trajectory2D &trajectory)
#define ecl_assert_throw_decl(exception)
Assure throw exception declaration.
const GenericPointer< typename T::ValueType > T2 value
#define ecl_compile_time_concept_check(Model)
Compile time concept checking assertion.
MatrixFormatter< Derived, Scalar > Formatter