Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
vec_concat.h
Go to the documentation of this file.
1#ifndef _RHEOLEF_VEC_CONCAT_H
2#define _RHEOLEF_VEC_CONCAT_H
23// build vec from initializer lists
24//
25#include "rheolef/vec.h"
26
27namespace rheolef { namespace details {
28
29// ----------------------------------------------------------------------------
30// 1) implementation
31// ----------------------------------------------------------------------------
32
34static int constraint_process_rank (const communicator& comm = communicator()) { return 0; }
35
36template <class T, class M>
38public:
39// typedef:
40 typedef enum { scalar, scalars, vector} variant_type;
41// allocators:
42 template <class U,
43 class Sfinae
44 = typename std::enable_if<
46 ,void
47 >::type
48 >
49 vec_concat_value (const U& x) : s(x), ss(), v(), variant(scalar) {}
50 vec_concat_value (const std::vector<T>& x) : s(), ss(x), v(), variant(scalars) {}
51 vec_concat_value (const vec<T,M>& x) : s(), ss(), v(x), variant(vector) {}
52// data:
53public:
55 std::vector<T> ss;
58};
59
60template <class T, class M>
62public:
63// typedef:
66
67// allocators:
68
69 vec_concat () : _l() {}
70 vec<T,M> build_vec() const;
71
72 vec_concat (const std::initializer_list<value_type>& il) : _l() {
73 typedef typename std::initializer_list<value_type>::const_iterator const_iterator;
74 for (const_iterator iter = il.begin(); iter != il.end(); ++iter) {
75 _l.push_back(*iter);
76 }
77 }
78
79// data:
80protected:
81 std::list<value_type> _l;
82};
83} // namespace details
84
85// ----------------------------------------------------------------------------
86// 2) interface with the vec<T,M> class
87// ----------------------------------------------------------------------------
88template <class T, class M>
89inline
90int
92{
93 return details::constraint_process_rank (base::comm());
94}
95template <class T, class M>
96inline
97vec<T,M>::vec (const std::initializer_list<details::vec_concat_value<T,M> >& init_list)
98{
99 details::vec_concat<T,M> vc (init_list);
101}
102template <class T, class M>
103inline
105vec<T,M>::operator= (const std::initializer_list<details::vec_concat_value<T,M> >& init_list)
106{
107 details::vec_concat<T,M> vc (init_list);
109 return *this;
110}
111
112} // namespace rheolef
113#endif // _RHEOLEF_VEC_CONCAT_H
see the communicator page for the full documentation
vec_concat_value(const vec< T, M > &x)
Definition vec_concat.h:51
vec_concat_value(const std::vector< T > &x)
Definition vec_concat.h:50
std::list< value_type > _l
Definition vec_concat.h:81
vec< T, M >::size_type size_type
Definition vec_concat.h:64
vec_concat(const std::initializer_list< value_type > &il)
Definition vec_concat.h:72
vec< T, M > build_vec() const
Definition vec_concat.cc:29
vec_concat_value< T, M > value_type
Definition vec_concat.h:65
see the vec page for the full documentation
Definition vec.h:79
base::size_type size_type
Definition vec.h:86
vec< T, M > & operator=(const vec< T, M > &x)
Definition vec.h:175
int constraint_process_rank() const
Definition vec_concat.h:91
vec(const vec< T, M > &)
Definition vec.h:168
Expr1::float_type T
Definition field_expr.h:230
This file is part of Rheolef.