// { dg-do compile }
|
// { dg-do compile }
|
// { dg-options "-O3 -floop-interchange -Wno-conversion-null" }
|
// { dg-options "-O3 -floop-interchange -Wno-conversion-null" }
|
|
|
void __throw_bad_alloc ();
|
void __throw_bad_alloc ();
|
|
|
template void
|
template void
|
swap (_Tp & __a, _Tp __b)
|
swap (_Tp & __a, _Tp __b)
|
{
|
{
|
__a = __b;
|
__a = __b;
|
}
|
}
|
|
|
template struct iterator
|
template struct iterator
|
{
|
{
|
typedef _Category iterator_category;
|
typedef _Category iterator_category;
|
};
|
};
|
|
|
template struct allocator
|
template struct allocator
|
{
|
{
|
typedef __SIZE_TYPE__ size_type;
|
typedef __SIZE_TYPE__ size_type;
|
typedef _Tp pointer;
|
typedef _Tp pointer;
|
pointer allocate (size_type)
|
pointer allocate (size_type)
|
{
|
{
|
__throw_bad_alloc ();
|
__throw_bad_alloc ();
|
return __null;
|
return __null;
|
}
|
}
|
};
|
};
|
|
|
template >class unbounded_array;
|
template >class unbounded_array;
|
template >class vector;
|
template >class vector;
|
template class scalar_vector;
|
template class scalar_vector;
|
template struct random_access_iterator_base : public iterator
|
template struct random_access_iterator_base : public iterator
|
{
|
{
|
};
|
};
|
|
|
template struct promote_traits
|
template struct promote_traits
|
{
|
{
|
typedef __typeof__ ((X ())) promote_type;
|
typedef __typeof__ ((X ())) promote_type;
|
};
|
};
|
|
|
template struct scalar_traits
|
template struct scalar_traits
|
{
|
{
|
typedef T const_reference;
|
typedef T const_reference;
|
typedef T reference;
|
typedef T reference;
|
};
|
};
|
|
|
template struct type_traits : scalar_traits
|
template struct type_traits : scalar_traits
|
{
|
{
|
};
|
};
|
|
|
struct dense_proxy_tag
|
struct dense_proxy_tag
|
{
|
{
|
};
|
};
|
|
|
template struct iterator_base_traits;
|
template struct iterator_base_traits;
|
|
|
template <> struct iterator_base_traits
|
template <> struct iterator_base_traits
|
{
|
{
|
template struct iterator_base
|
template struct iterator_base
|
{
|
{
|
typedef random_access_iterator_base type;
|
typedef random_access_iterator_base type;
|
};
|
};
|
};
|
};
|
|
|
template struct iterator_restrict_traits
|
template struct iterator_restrict_traits
|
{
|
{
|
typedef I1 iterator_category;
|
typedef I1 iterator_category;
|
};
|
};
|
|
|
template class storage_array
|
template class storage_array
|
{
|
{
|
};
|
};
|
|
|
template struct unbounded_array : public storage_array >
|
template struct unbounded_array : public storage_array >
|
{
|
{
|
typedef typename ALLOC::size_type size_type;
|
typedef typename ALLOC::size_type size_type;
|
typedef T & reference;
|
typedef T & reference;
|
typedef T *pointer;
|
typedef T *pointer;
|
unbounded_array (size_type size, ALLOC = ALLOC ()) : alloc_ (), size_ (size)
|
unbounded_array (size_type size, ALLOC = ALLOC ()) : alloc_ (), size_ (size)
|
{
|
{
|
alloc_.allocate (size_);
|
alloc_.allocate (size_);
|
}
|
}
|
~unbounded_array ()
|
~unbounded_array ()
|
{
|
{
|
if (size_)
|
if (size_)
|
for (;;);
|
for (;;);
|
}
|
}
|
size_type
|
size_type
|
size () const
|
size () const
|
{
|
{
|
return size_;
|
return size_;
|
}
|
}
|
reference
|
reference
|
operator[] (size_type i)
|
operator[] (size_type i)
|
{
|
{
|
return data_[i];
|
return data_[i];
|
}
|
}
|
void
|
void
|
swap (unbounded_array & a)
|
swap (unbounded_array & a)
|
{
|
{
|
::swap (size_, a.size_);
|
::swap (size_, a.size_);
|
}
|
}
|
ALLOC alloc_;
|
ALLOC alloc_;
|
size_type size_;
|
size_type size_;
|
pointer data_;
|
pointer data_;
|
};
|
};
|
|
|
template struct scalar_binary_functor
|
template struct scalar_binary_functor
|
{
|
{
|
typedef typename promote_traits ::promote_type result_type;
|
typedef typename promote_traits ::promote_type result_type;
|
};
|
};
|
|
|
template struct scalar_plus : public scalar_binary_functor
|
template struct scalar_plus : public scalar_binary_functor
|
{
|
{
|
};
|
};
|
|
|
template struct scalar_multiplies : public scalar_binary_functor
|
template struct scalar_multiplies : public scalar_binary_functor
|
{
|
{
|
};
|
};
|
|
|
template struct scalar_binary_assign_functor
|
template struct scalar_binary_assign_functor
|
{
|
{
|
typedef typename type_traits ::reference argument1_type;
|
typedef typename type_traits ::reference argument1_type;
|
typedef typename type_traits ::const_reference argument2_type;
|
typedef typename type_traits ::const_reference argument2_type;
|
};
|
};
|
|
|
template struct scalar_assign : public scalar_binary_assign_functor
|
template struct scalar_assign : public scalar_binary_assign_functor
|
{
|
{
|
typedef typename scalar_binary_assign_functor ::argument1_type argument1_type;
|
typedef typename scalar_binary_assign_functor ::argument1_type argument1_type;
|
typedef typename scalar_binary_assign_functor ::argument2_type argument2_type;
|
typedef typename scalar_binary_assign_functor ::argument2_type argument2_type;
|
static const bool computed = false;
|
static const bool computed = false;
|
static void
|
static void
|
apply (argument1_type t1, argument2_type t2)
|
apply (argument1_type t1, argument2_type t2)
|
{
|
{
|
t1 = t2;
|
t1 = t2;
|
}
|
}
|
};
|
};
|
|
|
template struct vector_expression
|
template struct vector_expression
|
{
|
{
|
typedef E expression_type;
|
typedef E expression_type;
|
const expression_type &
|
const expression_type &
|
operator () () const
|
operator () () const
|
{
|
{
|
return *static_cast (this);
|
return *static_cast (this);
|
}
|
}
|
};
|
};
|
|
|
template class vector_container : public vector_expression
|
template class vector_container : public vector_expression
|
{
|
{
|
};
|
};
|
|
|
template struct vector_reference : public vector_expression >
|
template struct vector_reference : public vector_expression >
|
{
|
{
|
typedef typename E::size_type size_type;
|
typedef typename E::size_type size_type;
|
typename E::const_reference const_reference;
|
typename E::const_reference const_reference;
|
typedef E referred_type;
|
typedef E referred_type;
|
vector_reference (referred_type & e) : e_ (e)
|
vector_reference (referred_type & e) : e_ (e)
|
{
|
{
|
}
|
}
|
size_type
|
size_type
|
size () const
|
size () const
|
{
|
{
|
return expression ().size ();
|
return expression ().size ();
|
}
|
}
|
referred_type &
|
referred_type &
|
expression () const
|
expression () const
|
{
|
{
|
return e_;
|
return e_;
|
}
|
}
|
referred_type &e_;
|
referred_type &e_;
|
};
|
};
|
|
|
template struct vector_binary : public vector_expression >
|
template struct vector_binary : public vector_expression >
|
{
|
{
|
typedef E1 expression1_type;
|
typedef E1 expression1_type;
|
typedef E2 expression2_type;
|
typedef E2 expression2_type;
|
typedef typename E1::const_closure_type expression1_closure_type;
|
typedef typename E1::const_closure_type expression1_closure_type;
|
typedef typename E2::const_closure_type expression2_closure_type;
|
typedef typename E2::const_closure_type expression2_closure_type;
|
typedef typename promote_traits ::promote_type size_type;
|
typedef typename promote_traits ::promote_type size_type;
|
typedef typename F::result_type value_type;
|
typedef typename F::result_type value_type;
|
|
|
vector_binary (const expression1_type & e1, expression2_type e2) : e1_ (e1), e2_ (e2)
|
vector_binary (const expression1_type & e1, expression2_type e2) : e1_ (e1), e2_ (e2)
|
{
|
{
|
}
|
}
|
|
|
size_type
|
size_type
|
size () const
|
size () const
|
{
|
{
|
return e1_.size ();
|
return e1_.size ();
|
}
|
}
|
|
|
class const_iterator : public iterator_base_traits ::iterator_category>::template iterator_base ::type
|
class const_iterator : public iterator_base_traits ::iterator_category>::template iterator_base ::type
|
{
|
{
|
};
|
};
|
expression1_closure_type e1_;
|
expression1_closure_type e1_;
|
expression2_closure_type e2_;
|
expression2_closure_type e2_;
|
};
|
};
|
|
|
template struct vector_binary_traits
|
template struct vector_binary_traits
|
{
|
{
|
typedef vector_binary expression_type;
|
typedef vector_binary expression_type;
|
typedef expression_type result_type;
|
typedef expression_type result_type;
|
};
|
};
|
|
|
template typename vector_binary_traits >::result_type
|
template typename vector_binary_traits >::result_type
|
operator + (vector_expression &e1, const vector_expression &e2)
|
operator + (vector_expression &e1, const vector_expression &e2)
|
{
|
{
|
typedef typename vector_binary_traits >::expression_type expression_type;
|
typedef typename vector_binary_traits >::expression_type expression_type;
|
return expression_type (e1 (), e2 ());
|
return expression_type (e1 (), e2 ());
|
}
|
}
|
|
|
template struct vector_binary_scalar2 : public vector_expression >
|
template struct vector_binary_scalar2 : public vector_expression >
|
{
|
{
|
typedef vector_binary_scalar2 self_type;
|
typedef vector_binary_scalar2 self_type;
|
typedef typename E1::size_type size_type;
|
typedef typename E1::size_type size_type;
|
typedef typename F::result_type value_type;
|
typedef typename F::result_type value_type;
|
typedef self_type const_closure_type;
|
typedef self_type const_closure_type;
|
};
|
};
|
|
|
template struct vector_binary_scalar2_traits
|
template struct vector_binary_scalar2_traits
|
{
|
{
|
typedef vector_binary_scalar2 result_type;
|
typedef vector_binary_scalar2 result_type;
|
};
|
};
|
|
|
template
|
template
|
typename vector_binary_scalar2_traits >::result_type
|
typename vector_binary_scalar2_traits >::result_type
|
operator * (vector_expression , T2)
|
operator * (vector_expression , T2)
|
{
|
{
|
}
|
}
|
|
|
template struct vector_assign_traits
|
template struct vector_assign_traits
|
{
|
{
|
typedef SC storage_category;
|
typedef SC storage_category;
|
};
|
};
|
|
|
template class F, class V, class E> void
|
template class F, class V, class E> void
|
indexing_vector_assign (V & v, vector_expression )
|
indexing_vector_assign (V & v, vector_expression )
|
{
|
{
|
typedef F functor_type;
|
typedef F functor_type;
|
typedef typename V::size_type size_type;
|
typedef typename V::size_type size_type;
|
size_type size (v.size ());
|
size_type size (v.size ());
|
for (size_type i; i
|
for (size_type i; i
|
functor_type::apply (v (i), (i));
|
functor_type::apply (v (i), (i));
|
}
|
}
|
|
|
template class F, class V, class E> void
|
template class F, class V, class E> void
|
vector_assign (V & v, const vector_expression &e, dense_proxy_tag)
|
vector_assign (V & v, const vector_expression &e, dense_proxy_tag)
|
{
|
{
|
indexing_vector_assign (v, e);
|
indexing_vector_assign (v, e);
|
}
|
}
|
|
|
template class F, class V, class E> void
|
template class F, class V, class E> void
|
vector_assign (V & v, const vector_expression &e)
|
vector_assign (V & v, const vector_expression &e)
|
{
|
{
|
typedef typename vector_assign_traits ::storage_category storage_category;
|
typedef typename vector_assign_traits ::storage_category storage_category;
|
vector_assign (v, e, storage_category ());
|
vector_assign (v, e, storage_category ());
|
}
|
}
|
|
|
template struct vector : public vector_container >
|
template struct vector : public vector_container >
|
{
|
{
|
typedef vector self_type;
|
typedef vector self_type;
|
typedef typename A::size_type size_type;
|
typedef typename A::size_type size_type;
|
typedef T value_type;
|
typedef T value_type;
|
typedef typename type_traits ::const_reference const_reference;
|
typedef typename type_traits ::const_reference const_reference;
|
typedef T &reference;
|
typedef T &reference;
|
typedef A array_type;
|
typedef A array_type;
|
typedef vector_reference const_closure_type;
|
typedef vector_reference const_closure_type;
|
typedef dense_proxy_tag storage_category;
|
typedef dense_proxy_tag storage_category;
|
vector (size_type size):vector_container (), data_ (size)
|
vector (size_type size):vector_container (), data_ (size)
|
{
|
{
|
}
|
}
|
vector (size_type size, value_type):vector_container (), data_ (size)
|
vector (size_type size, value_type):vector_container (), data_ (size)
|
{
|
{
|
}
|
}
|
template vector (const vector_expression &ae) : vector_container (), data_ (ae ().size ())
|
template vector (const vector_expression &ae) : vector_container (), data_ (ae ().size ())
|
{
|
{
|
vector_assign (*this, ae);
|
vector_assign (*this, ae);
|
}
|
}
|
size_type
|
size_type
|
size () const
|
size () const
|
{
|
{
|
return data_.size ();
|
return data_.size ();
|
}
|
}
|
array_type &
|
array_type &
|
data ()
|
data ()
|
{
|
{
|
return data_;
|
return data_;
|
}
|
}
|
reference
|
reference
|
operator () (size_type i)
|
operator () (size_type i)
|
{
|
{
|
return data ()[i];
|
return data ()[i];
|
}
|
}
|
template vector operator += (const vector_expression &ae)
|
template vector operator += (const vector_expression &ae)
|
{
|
{
|
self_type temporary (*this + ae);
|
self_type temporary (*this + ae);
|
data_.swap (temporary.data ());
|
data_.swap (temporary.data ());
|
return *this;
|
return *this;
|
}
|
}
|
class const_iterator : public random_access_iterator_base
|
class const_iterator : public random_access_iterator_base
|
{
|
{
|
};
|
};
|
array_type data_;
|
array_type data_;
|
};
|
};
|
|
|
template struct scalar_vector : public vector_container >
|
template struct scalar_vector : public vector_container >
|
{
|
{
|
typedef scalar_vector self_type;
|
typedef scalar_vector self_type;
|
typedef __SIZE_TYPE__ size_type;
|
typedef __SIZE_TYPE__ size_type;
|
typedef T value_type;
|
typedef T value_type;
|
typedef T const_reference;
|
typedef T const_reference;
|
typedef vector_reference const_closure_type;
|
typedef vector_reference const_closure_type;
|
};
|
};
|
|
|
void
|
void
|
bar (vector )
|
bar (vector )
|
{
|
{
|
}
|
}
|
|
|
void
|
void
|
foo (int n_samp)
|
foo (int n_samp)
|
{
|
{
|
vector xi (n_samp, 0);
|
vector xi (n_samp, 0);
|
for (int n = 0; n
|
for (int n = 0; n
|
{
|
{
|
vector cos_w_n (n_samp);
|
vector cos_w_n (n_samp);
|
xi += cos_w_n * 6.0;
|
xi += cos_w_n * 6.0;
|
}
|
}
|
vector cos_wd (n_samp);
|
vector cos_wd (n_samp);
|
xi += cos_wd;
|
xi += cos_wd;
|
bar (xi + scalar_vector <> ());
|
bar (xi + scalar_vector <> ());
|
}
|
}
|
|
|