10 T* ptr(T &x) {
return &x; }
11 size_t size(T &x) {
return 1; }
14 struct concat_traits_vector {
15 typedef typename VT::value_type value_type;
17 T* ptr(VT &x) {
return x.data(); }
18 size_t size(VT &x) {
return x.size(); }
21 struct concat_traits<vector<T> > : concat_traits_vector<vector<T> > {};
23 struct concat_traits<matrix<T> > : concat_traits_vector<matrix<T> > {};
25 struct concat_traits<array<T> > : concat_traits_vector<array<T> > {};
28 template<
class S=void,
class...Ts>
32 typedef typename concat_traits<S>::value_type value_type;
33 void assign_from(
const value_type* x) {
34 value_type* dest = concat_traits<S>().ptr(cur);
35 size_t n = concat_traits<S>().size(cur);
36 for (
size_t i=0; i<n; i++) {dest[i] = *x; x++;}
39 void assign_to(value_type* x) {
40 value_type* orig = concat_traits<S>().ptr(cur);
41 size_t n = concat_traits<S>().size(cur);
42 for (
size_t i=0; i<n; i++) {*x = orig[i]; x++;}
45 size_t size() {
return concat_traits<S>().size(cur) + next.size(); }
48 assign_to(ans.data());
52 assign_from(x.data());
59 void assign_from(T x) { }
61 void assign_to(T x) { }
62 size_t size() {
return 0; }
96 return Concat<Ts...>({args...});
Concat< Ts... > concat(Ts &... args)
Serialized representation of objects of different types.
Vector class used by TMB.
Serialized representation of objects of different types.
Utility functions for TMB (automatically included)