00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
01298 #ifndef ARRAY_HPP
01299 #define ARRAY_HPP
01300
01301 #include <exception>
01302 #include <stdexcept>
01303 #include <iterator>
01304 #include <algorithm>
01305 #include <iostream>
01306 #include <iomanip>
01307 #include <limits>
01308 #include <cmath>
01309 #include <cstdlib>
01310
01311
01312
01313
01314
01315 #ifdef LITE_INLINE
01316 #undef LITE_INLINE
01317 #endif
01318
01323 #define LITE_ARRAY_MAX_DIMS 3
01324
01329 #define LITE_ARRAY_MAX_PACKS 4
01330
01343 #define LITE_ARRAY_MAX_VECTOR_ARGS 5
01344
01352 #define LITE_ARRAY_MAX_ITERATOR_ARGS 3
01353
01360 #define LITE_ARRAY_MAX_STATIC_UNROLL_LENGTH 5
01361
01370 #define LITE_ARRAY_MAX_DYNAMIC_UNROLL_DEPTH 4
01371
01376 #define LITE_ARRAY_VERSION 3501
01377
01382 #define LITE_ARRAY_VERSION_STR "3.501"
01383
01384 #define LITE_ARRAY_USE(x) ((void)(x))
01385
01386 #ifndef __LINE__ // true when Doxygen is processing the file
01387 #define DOCUMENTATION_ONLY
01388 #endif
01389
01390
01391
01392
01393
01394 #ifdef _MSC_VER
01395
01396 #if _MSC_VER < 1300
01397 #error visual c++ .net 7.1 (2003) or newer is required
01398 #endif // _MSC_VER < 1300
01399
01400 #pragma warning(push)
01401 #pragma warning(disable : 4127) // conditional_c expression is constant
01402 #pragma inline_recursion(on)
01403 #pragma inline_depth(200)
01404
01405 #define LITE_INLINE __forceinline
01406
01407 #ifndef NDEBUG
01408 #pragma message ("lite/array.hpp: Warning! Possible performance penalty due to assertions. Define NDEBUG to disable.")
01409 #endif
01410
01411 #endif // _MSC_VER
01412
01413
01414
01415
01416
01417 #ifdef __GNUC__
01418
01419 #define LITE_INLINE inline __attribute__((always_inline))
01420
01421 #ifndef LITE_ARRAY_NO_HINT
01422 #warning "Use the following compiler switches to get a good performance: -finline-limit=1234567 --param large-function-growth=1234567 --param max-inline-insns-single=1234567"
01423 #warning "Define LITE_ARRAY_NO_HINT to disable the previous warning."
01424 #endif
01425
01426 #ifndef NDEBUG
01427 #warning "lite/array.hpp: Possible performance penalty due to assertions. Define NDEBUG to disable."
01428 #endif
01429
01430 #endif // __GNUC__
01431
01432
01433
01434
01435
01436 #ifndef LITE_INLINE
01437 #define LITE_INLINE inline
01438 #endif
01439
01440
01441
01442
01443
01444 #ifdef NDEBUG
01445 #define LITE_ARRAY_SIZE_CHECK(size1, size2, msg)
01446 #else
01447 #define LITE_ARRAY_SIZE_CHECK(size1, size2, msg) lite_array_size_check(size1, size2, msg)
01448 #endif
01449
01450
01451
01452
01453
01455 namespace lite
01456 {
01457
01458 template<typename type_, type_ value_>
01459 class constant;
01460
01461 template<
01462 typename type0_ = void ,
01463 typename type1_ = void ,
01464 typename type2_ = void ,
01465 typename type3_ = void
01466 >
01467 class pack;
01468
01469 template<
01470 typename pack_type_,
01471 bool keep0_ =false,
01472 bool keep1_ =false,
01473 bool keep2_ =false,
01474 bool keep3_ =false
01475 >
01476 class sub_pack;
01477
01478
01479
01480 template<typename _value_type>
01481 class c_iterator;
01482
01483 template<
01484 typename base_iter_type_,
01485 typename func_type_,
01486 bool is_static_ =true>
01487 class u_iterator;
01488
01489 template<
01490 typename left_base_iter_type_,
01491 typename right_base_iter_type_,
01492 typename func_type_,
01493 bool is_static_=true>
01494 class b_iterator;
01495
01496 template<typename signature_, typename base_iterator_type_=void>
01497 struct array_signature_traits;
01498
01499 template<typename iterator_type_>
01500 class reference_rep;
01501
01502 template<bool reversed_>
01503 class internal_rep;
01504
01505 template<bool reversed_, int internal_buf_size_>
01506 class hybrid_rep;
01507
01508 struct default_array_traits;
01509
01510 template<
01511 typename signature_,
01512 typename traits_type_ = default_array_traits,
01513 typename rep_ = typename traits_type_::template representation_type<signature_>::type>
01514 class array;
01515
01516 template<typename signature_, typename traits_type_ = default_array_traits>
01517 struct array_helper;
01518
01519 template<typename trans_type_, typename size_type_>
01520 struct size_transformer;
01521
01522 template<typename trans_type_, typename iter_type_, typename size_type_>
01523 struct iterator_transformer;
01524
01525 template<typename array_type_, typename trans_type_, typename enabler_=void>
01526 struct transform_traits;
01527
01528 template<int dim_>
01529 class plane;
01530
01552 typedef plane<0> row;
01553
01575 typedef plane<1> column;
01576
01577 class diagonal;
01578
01579 class transpose;
01580
01581 template<
01582 int n0_ = -2,
01583 int n1_ = -2,
01584 int n2_ = -2
01585 >
01586 class block;
01587
01588 class array_comparator;
01589
01590 class size_mismatch_error;
01591
01600 namespace transforms
01601 {
01602 using ::lite::plane;
01603 using ::lite::row;
01604 using ::lite::column;
01605 using ::lite::diagonal;
01606 using ::lite::transpose;
01607 using ::lite::block;
01608 using ::lite::transform_traits;
01609 };
01610
01611
01612
01613
01614
01615 namespace detail
01616 {
01617
01618
01619
01620
01621
01622 template<bool cond_, typename type_ =void>
01623 struct enable_if;
01624
01625 template<typename type_>
01626 struct enable_if<false, type_>
01627 {};
01628
01629 template<typename type_>
01630 struct enable_if<true, type_>
01631 {
01632 typedef type_ type;
01633 };
01634
01635
01636
01637
01638
01639 template<bool cond_, typename true_type_, typename false_type_>
01640 struct type_if;
01641
01642 template<typename true_type_, typename false_type_>
01643 struct type_if<true, true_type_, false_type_>
01644 {
01645 typedef true_type_ type;
01646 };
01647
01648 template<typename true_type_, typename false_type_>
01649 struct type_if<false, true_type_, false_type_>
01650 {
01651 typedef false_type_ type;
01652 };
01653
01654 struct invalid_argument {};
01655
01656
01657
01658
01659
01660 template<typename left_type_, typename right_type_>
01661 struct same_type
01662 {
01663 static const bool result = false;
01664 };
01665
01666 template<typename type_>
01667 struct same_type<type_, type_>
01668 {
01669 static const bool result = true;
01670 };
01671
01672
01673
01674
01675
01676 template<typename type_>
01677 struct defined
01678 {
01679 static const bool value = true;
01680 };
01681
01682
01683
01684
01685
01686 template<bool cond_>
01687 struct compile_time_assert;
01688
01689 template<>
01690 struct compile_time_assert<true>
01691 {
01692 typedef void verified;
01693 };
01694
01695
01696
01697
01698
01699 template<typename type_, typename stencil_, typename other_>
01700 struct remove_4
01701 {
01702 typedef type_ type;
01703 typedef other_ other;
01704 };
01705
01706 template<typename type_, typename stencil_, typename other_>
01707 struct remove_4<volatile type_, volatile stencil_, other_>
01708 {
01709 typedef type_ type;
01710 typedef volatile other_ other;
01711 };
01712
01713
01714
01715 template<typename type_, typename stencil_, typename other_>
01716 struct remove_3
01717 {
01718 typedef typename remove_4<type_, stencil_, other_>::type type;
01719 typedef typename remove_4<type_, stencil_, other_>::other other;
01720 };
01721
01722 template<typename type_, typename stencil_, typename other_>
01723 struct remove_3<const type_, const stencil_, other_>
01724 {
01725 typedef typename remove_4<type_, stencil_, other_>::type type;
01726 typedef const typename remove_4<type_, stencil_, other_>::other other;
01727 };
01728
01729
01730
01731 template<typename type_, typename stencil_, typename other_>
01732 struct remove_2
01733 {
01734 typedef typename remove_3<type_, stencil_, other_>::type type;
01735 typedef typename remove_3<type_, stencil_, other_>::other other;
01736 };
01737
01738 template<typename type_, typename stencil_, typename other_>
01739 struct remove_2<type_*, stencil_*, other_>
01740 {
01741 typedef typename remove_3<type_, stencil_, other_>::type type;
01742 typedef typename remove_3<type_, stencil_, other_>::other* other;
01743 };
01744
01745
01746
01747 template<typename type_, typename stencil_, typename other_>
01748 struct remove_1
01749 {
01750 typedef typename remove_2<type_, stencil_, other_>::type type;
01751 typedef typename remove_2<type_, stencil_, other_>::other other;
01752 };
01753
01754 template<typename type_, typename stencil_, typename other_>
01755 struct remove_1<type_&, stencil_&, other_>
01756 {
01757 typedef typename remove_2<type_, stencil_, other_>::type type;
01758 typedef typename remove_2<type_, stencil_, other_>::other& other;
01759 };
01760
01761
01762
01763 template<typename type_, typename stencil_, typename other_=int>
01764 struct remove
01765 {
01766 typedef typename remove_1<type_, stencil_, other_>::type type;
01767 typedef typename remove_1<type_, stencil_, other_>::other other;
01768 };
01769
01770
01771
01772
01773
01774 template<typename dim_type_>
01775 struct dim_type_to_sig;
01776
01777 template<>
01778 struct dim_type_to_sig<int>
01779 { static const int n = 1; };
01780
01781 template<int n_>
01782 struct dim_type_to_sig<constant<int, n_> >
01783 { static const int n = n_; };
01784
01785 template<typename size_type_, typename value_type_>
01786 struct size_to_signature;
01787
01788
01789 template<
01790 typename value_type_>
01791 struct size_to_signature<pack<
01792 >,
01793 value_type_>
01794 {
01795 typedef value_type_ type
01796 ;
01797 };
01798
01799 template<
01800 typename type0_,
01801 typename value_type_>
01802 struct size_to_signature<pack<
01803 type0_
01804 >,
01805 value_type_>
01806 {
01807 typedef value_type_ type
01808 [dim_type_to_sig<type0_>::n]
01809 ;
01810 };
01811
01812 template<
01813 typename type0_,
01814 typename type1_,
01815 typename value_type_>
01816 struct size_to_signature<pack<
01817 type0_,
01818 type1_
01819 >,
01820 value_type_>
01821 {
01822 typedef value_type_ type
01823 [dim_type_to_sig<type0_>::n]
01824 [dim_type_to_sig<type1_>::n]
01825 ;
01826 };
01827
01828 template<
01829 typename type0_,
01830 typename type1_,
01831 typename type2_,
01832 typename value_type_>
01833 struct size_to_signature<pack<
01834 type0_,
01835 type1_,
01836 type2_
01837 >,
01838 value_type_>
01839 {
01840 typedef value_type_ type
01841 [dim_type_to_sig<type0_>::n]
01842 [dim_type_to_sig<type1_>::n]
01843 [dim_type_to_sig<type2_>::n]
01844 ;
01845 };
01846
01847 }
01848
01849
01850
01851
01852
01858 class size_mismatch_error
01859 : public std::runtime_error
01860 {
01861 public:
01862 size_mismatch_error(const std::string& msg ="")
01863 : std::runtime_error(msg)
01864 {}
01865
01866 ~size_mismatch_error() throw() {}
01867 };
01868
01869
01870
01871
01872
01887 template<typename type_, type_ value_>
01888 class constant
01889 {
01890 public:
01891 typedef type_ type;
01892 static const type_ value = value_;
01893 };
01894
01895 template<typename type_, type_ value_>
01896 const type_ constant<type_, value_>::value;
01897
01898 #ifdef DOCUMENTATION_ONLY
01899
01978 template<typename type0_ ..., typename typeN_>
01979 class pack
01980 {
01981 public:
01982 static const int n = N+1;
01983
01984 typedef ... typeX;
01985
01986 static const bool is_constX = ...;
01987
01988 static const bool is_all_const = ...;
01989
01990 static const typeX iX = valueX_;
01991
01992 typeX iX;
01993
01995 pack();
01996
01998 pack(const type0& a0);
01999
02001 pack(const type0& a0, ... , const typeN& aN);
02002
02004 template<typename other_type0_, ... , typename other_typeN_>
02005 pack(const pack<other_type0_, ... , other_typeN_>& other);
02006
02008 pack&
02009 operator= (const pack& other);
02010
02012 template<typename other_type0_, ... , typename other_typeN_>
02013 pack&
02014 operator= (const pack<other_type0_, ... , other_typeN_>& other);
02015
02017 void set(const type0& a0, ... , const typeN& aN);
02018 };
02019
02020 #else // DOCUMENTATION_ONLY
02021
02022 template<
02023 typename type0_,
02024 typename type1_,
02025 typename type2_,
02026 typename type3_
02027 >
02028 class pack
02029 {
02030 public:
02031 static const int n = 4;
02032
02033 typedef type0_ type0;
02034 typedef type1_ type1;
02035 typedef type2_ type2;
02036 typedef type3_ type3;
02037
02038 static const bool is_const0 = false;
02039 static const bool is_const1 = false;
02040 static const bool is_const2 = false;
02041 static const bool is_const3 = false;
02042 static const bool is_all_const = false;
02043 type0 i0;
02044 type1 i1;
02045 type2 i2;
02046 type3 i3;
02047
02048 LITE_INLINE pack()
02049 : i0(),i1(),i2(),i3() {}
02050
02051 LITE_INLINE pack(const type0& a0)
02052 : i0(a0)
02053 {}
02054
02055 LITE_INLINE pack(
02056 const type0& a0,
02057 const type1& a1,
02058 const type2& a2,
02059 const type3& a3
02060 ) : i0(a0), i1(a1), i2(a2), i3(a3) {}
02061
02062 template<
02063 typename other_type0_ ,
02064 typename other_type1_ ,
02065 typename other_type2_ ,
02066 typename other_type3_
02067 >
02068 LITE_INLINE pack(const pack<
02069 other_type0_,
02070 other_type1_,
02071 other_type2_,
02072 other_type3_
02073 >& other) : i0(other.i0), i1(other.i1), i2(other.i2), i3(other.i3) {}
02074
02075 LITE_INLINE pack&
02076 operator= (const pack& other)
02077 {
02078 i0 = other.i0;
02079 i1 = other.i1;
02080 i2 = other.i2;
02081 i3 = other.i3;
02082 return *this;
02083 }
02084
02085 template<
02086 typename other_type0_ ,
02087 typename other_type1_ ,
02088 typename other_type2_ ,
02089 typename other_type3_
02090 >
02091 LITE_INLINE pack&
02092 operator=(const pack<
02093 other_type0_,
02094 other_type1_,
02095 other_type2_,
02096 other_type3_
02097 >& other)
02098 {
02099 i0 = other.i0;
02100 i1 = other.i1;
02101 i2 = other.i2;
02102 i3 = other.i3;
02103 return *this;
02104 }
02105
02106 LITE_INLINE void set(
02107 const type0& a0,
02108 const type1& a1,
02109 const type2& a2,
02110 const type3& a3
02111 )
02112 {
02113 i0 = a0;
02114 i1 = a1;
02115 i2 = a2;
02116 i3 = a3;
02117 }
02118 };
02119
02120
02121
02122 template<
02123 typename type0_, type0_ value0_,
02124 typename type1_,
02125 typename type2_,
02126 typename type3_
02127 >
02128 class pack<
02129 constant<type0_, value0_>,
02130 type1_,
02131 type2_,
02132 type3_
02133 >
02134 {
02135 public:
02136 static const int n = 4;
02137
02138 typedef type0_ type0;
02139 typedef type1_ type1;
02140 typedef type2_ type2;
02141 typedef type3_ type3;
02142
02143 static const bool is_const0 = true;
02144 static const bool is_const1 = false;
02145 static const bool is_const2 = false;
02146 static const bool is_const3 = false;
02147 static const bool is_all_const = false;
02148 static const type0 i0 = value0_;
02149 type1 i1;
02150 type2 i2;
02151 type3 i3;
02152
02153 LITE_INLINE pack()
02154 : i1(),i2(),i3() {}
02155
02156 LITE_INLINE pack(const type0& )
02157 {}
02158
02159 LITE_INLINE pack(
02160 const type0& ,
02161 const type1& a1,
02162 const type2& a2,
02163 const type3& a3
02164 ) : i1(a1), i2(a2), i3(a3) {}
02165
02166 template<
02167 typename other_type0_ ,
02168 typename other_type1_ ,
02169 typename other_type2_ ,
02170 typename other_type3_
02171 >
02172 LITE_INLINE pack(const pack<
02173 other_type0_,
02174 other_type1_,
02175 other_type2_,
02176 other_type3_
02177 >& other) : i1(other.i1), i2(other.i2), i3(other.i3) {}
02178
02179 LITE_INLINE pack&
02180 operator= (const pack& other)
02181 {
02182 i1 = other.i1;
02183 i2 = other.i2;
02184 i3 = other.i3;
02185 return *this;
02186 }
02187
02188 template<
02189 typename other_type0_ ,
02190 typename other_type1_ ,
02191 typename other_type2_ ,
02192 typename other_type3_
02193 >
02194 LITE_INLINE pack&
02195 operator=(const pack<
02196 other_type0_,
02197 other_type1_,
02198 other_type2_,
02199 other_type3_
02200 >& other)
02201 {
02202 i1 = other.i1;
02203 i2 = other.i2;
02204 i3 = other.i3;
02205 return *this;
02206 }
02207
02208 LITE_INLINE void set(
02209 const type0& ,
02210 const type1& a1,
02211 const type2& a2,
02212 const type3& a3
02213 )
02214 {
02215 i1 = a1;
02216 i2 = a2;
02217 i3 = a3;
02218 }
02219 };
02220
02221
02222 template<
02223 typename type0_, type0_ value0_,
02224 typename type1_,
02225 typename type2_,
02226 typename type3_
02227 >
02228 const type0_ pack<
02229 constant<type0_, value0_>,
02230 type1_,
02231 type2_,
02232 type3_
02233 >::i0;
02234
02235
02236 template<
02237 typename type0_,
02238 typename type1_, type1_ value1_,
02239 typename type2_,
02240 typename type3_
02241 >
02242 class pack<
02243 type0_,
02244 constant<type1_, value1_>,
02245 type2_,
02246 type3_
02247 >
02248 {
02249 public:
02250 static const int n = 4;
02251
02252 typedef type0_ type0;
02253 typedef type1_ type1;
02254 typedef type2_ type2;
02255 typedef type3_ type3;
02256
02257 static const bool is_const0 = false;
02258 static const bool is_const1 = true;
02259 static const bool is_const2 = false;
02260 static const bool is_const3 = false;
02261 static const bool is_all_const = false;
02262 type0 i0;
02263 static const type1 i1 = value1_;
02264 type2 i2;
02265 type3 i3;
02266
02267 LITE_INLINE pack()
02268 : i0(),i2(),i3() {}
02269
02270 LITE_INLINE pack(const type0& a0)
02271 : i0(a0)
02272 {}
02273
02274 LITE_INLINE pack(
02275 const type0& a0,
02276 const type1& ,
02277 const type2& a2,
02278 const type3& a3
02279 ) : i0(a0), i2(a2), i3(a3) {}
02280
02281 template<
02282 typename other_type0_ ,
02283 typename other_type1_ ,
02284 typename other_type2_ ,
02285 typename other_type3_
02286 >
02287 LITE_INLINE pack(const pack<
02288 other_type0_,
02289 other_type1_,
02290 other_type2_,
02291 other_type3_
02292 >& other) : i0(other.i0), i2(other.i2), i3(other.i3) {}
02293
02294 LITE_INLINE pack&
02295 operator= (const pack& other)
02296 {
02297 i0 = other.i0;
02298 i2 = other.i2;
02299 i3 = other.i3;
02300 return *this;
02301 }
02302
02303 template<
02304 typename other_type0_ ,
02305 typename other_type1_ ,
02306 typename other_type2_ ,
02307 typename other_type3_
02308 >
02309 LITE_INLINE pack&
02310 operator=(const pack<
02311 other_type0_,
02312 other_type1_,
02313 other_type2_,
02314 other_type3_
02315 >& other)
02316 {
02317 i0 = other.i0;
02318 i2 = other.i2;
02319 i3 = other.i3;
02320 return *this;
02321 }
02322
02323 LITE_INLINE void set(
02324 const type0& a0,
02325 const type1& ,
02326 const type2& a2,
02327 const type3& a3
02328 )
02329 {
02330 i0 = a0;
02331 i2 = a2;
02332 i3 = a3;
02333 }
02334 };
02335
02336
02337 template<
02338 typename type0_,
02339 typename type1_, type1_ value1_,
02340 typename type2_,
02341 typename type3_
02342 >
02343 const type1_ pack<
02344 type0_,
02345 constant<type1_, value1_>,
02346 type2_,
02347 type3_
02348 >::i1;
02349
02350
02351 template<
02352 typename type0_, type0_ value0_,
02353 typename type1_, type1_ value1_,
02354 typename type2_,
02355 typename type3_
02356 >
02357 class pack<
02358 constant<type0_, value0_>,
02359 constant<type1_, value1_>,
02360 type2_,
02361 type3_
02362 >
02363 {
02364 public:
02365 static const int n = 4;
02366
02367 typedef type0_ type0;
02368 typedef type1_ type1;
02369 typedef type2_ type2;
02370 typedef type3_ type3;
02371
02372 static const bool is_const0 = true;
02373 static const bool is_const1 = true;
02374 static const bool is_const2 = false;
02375 static const bool is_const3 = false;
02376 static const bool is_all_const = false;
02377 static const type0 i0 = value0_;
02378 static const type1 i1 = value1_;
02379 type2 i2;
02380 type3 i3;
02381
02382 LITE_INLINE pack()
02383 : i2(),i3() {}
02384
02385 LITE_INLINE pack(const type0& )
02386 {}
02387
02388 LITE_INLINE pack(
02389 const type0& ,
02390 const type1& ,
02391 const type2& a2,
02392 const type3& a3
02393 ) : i2(a2), i3(a3) {}
02394
02395 template<
02396 typename other_type0_ ,
02397 typename other_type1_ ,
02398 typename other_type2_ ,
02399 typename other_type3_
02400 >
02401 LITE_INLINE pack(const pack<
02402 other_type0_,
02403 other_type1_,
02404 other_type2_,
02405 other_type3_
02406 >& other) : i2(other.i2), i3(other.i3) {}
02407
02408 LITE_INLINE pack&
02409 operator= (const pack& other)
02410 {
02411 i2 = other.i2;
02412 i3 = other.i3;
02413 return *this;
02414 }
02415
02416 template<
02417 typename other_type0_ ,
02418 typename other_type1_ ,
02419 typename other_type2_ ,
02420 typename other_type3_
02421 >
02422 LITE_INLINE pack&
02423 operator=(const pack<
02424 other_type0_,
02425 other_type1_,
02426 other_type2_,
02427 other_type3_
02428 >& other)
02429 {
02430 i2 = other.i2;
02431 i3 = other.i3;
02432 return *this;
02433 }
02434
02435 LITE_INLINE void set(
02436 const type0& ,
02437 const type1& ,
02438 const type2& a2,
02439 const type3& a3
02440 )
02441 {
02442 i2 = a2;
02443 i3 = a3;
02444 }
02445 };
02446
02447
02448 template<
02449 typename type0_, type0_ value0_,
02450 typename type1_, type1_ value1_,
02451 typename type2_,
02452 typename type3_
02453 >
02454 const type0_ pack<
02455 constant<type0_, value0_>,
02456 constant<type1_, value1_>,
02457 type2_,
02458 type3_
02459 >::i0;
02460
02461 template<
02462 typename type0_, type0_ value0_,
02463 typename type1_, type1_ value1_,
02464 typename type2_,
02465 typename type3_
02466 >
02467 const type1_ pack<
02468 constant<type0_, value0_>,
02469 constant<type1_, value1_>,
02470 type2_,
02471 type3_
02472 >::i1;
02473
02474
02475 template<
02476 typename type0_,
02477 typename type1_,
02478 typename type2_, type2_ value2_,
02479 typename type3_
02480 >
02481 class pack<
02482 type0_,
02483 type1_,
02484 constant<type2_, value2_>,
02485 type3_
02486 >
02487 {
02488 public:
02489 static const int n = 4;
02490
02491 typedef type0_ type0;
02492 typedef type1_ type1;
02493 typedef type2_ type2;
02494 typedef type3_ type3;
02495
02496 static const bool is_const0 = false;
02497 static const bool is_const1 = false;
02498 static const bool is_const2 = true;
02499 static const bool is_const3 = false;
02500 static const bool is_all_const = false;
02501 type0 i0;
02502 type1 i1;
02503 static const type2 i2 = value2_;
02504 type3 i3;
02505
02506 LITE_INLINE pack()
02507 : i0(),i1(),i3() {}
02508
02509 LITE_INLINE pack(const type0& a0)
02510 : i0(a0)
02511 {}
02512
02513 LITE_INLINE pack(
02514 const type0& a0,
02515 const type1& a1,
02516 const type2& ,
02517 const type3& a3
02518 ) : i0(a0), i1(a1), i3(a3) {}
02519
02520 template<
02521 typename other_type0_ ,
02522 typename other_type1_ ,
02523 typename other_type2_ ,
02524 typename other_type3_
02525 >
02526 LITE_INLINE pack(const pack<
02527 other_type0_,
02528 other_type1_,
02529 other_type2_,
02530 other_type3_
02531 >& other) : i0(other.i0), i1(other.i1), i3(other.i3) {}
02532
02533 LITE_INLINE pack&
02534 operator= (const pack& other)
02535 {
02536 i0 = other.i0;
02537 i1 = other.i1;
02538 i3 = other.i3;
02539 return *this;
02540 }
02541
02542 template<
02543 typename other_type0_ ,
02544 typename other_type1_ ,
02545 typename other_type2_ ,
02546 typename other_type3_
02547 >
02548 LITE_INLINE pack&
02549 operator=(const pack<
02550 other_type0_,
02551 other_type1_,
02552 other_type2_,
02553 other_type3_
02554 >& other)
02555 {
02556 i0 = other.i0;
02557 i1 = other.i1;
02558 i3 = other.i3;
02559 return *this;
02560 }
02561
02562 LITE_INLINE void set(
02563 const type0& a0,
02564 const type1& a1,
02565 const type2& ,
02566 const type3& a3
02567 )
02568 {
02569 i0 = a0;
02570 i1 = a1;
02571 i3 = a3;
02572 }
02573 };
02574
02575
02576 template<
02577 typename type0_,
02578 typename type1_,
02579 typename type2_, type2_ value2_,
02580 typename type3_
02581 >
02582 const type2_ pack<
02583 type0_,
02584 type1_,
02585 constant<type2_, value2_>,
02586 type3_
02587 >::i2;
02588
02589
02590 template<
02591 typename type0_, type0_ value0_,
02592 typename type1_,
02593 typename type2_, type2_ value2_,
02594 typename type3_
02595 >
02596 class pack<
02597 constant<type0_, value0_>,
02598 type1_,
02599 constant<type2_, value2_>,
02600 type3_
02601 >
02602 {
02603 public:
02604 static const int n = 4;
02605
02606 typedef type0_ type0;
02607 typedef type1_ type1;
02608 typedef type2_ type2;
02609 typedef type3_ type3;
02610
02611 static const bool is_const0 = true;
02612 static const bool is_const1 = false;
02613 static const bool is_const2 = true;
02614 static const bool is_const3 = false;
02615 static const bool is_all_const = false;
02616 static const type0 i0 = value0_;
02617 type1 i1;
02618 static const type2 i2 = value2_;
02619 type3 i3;
02620
02621 LITE_INLINE pack()
02622 : i1(),i3() {}
02623
02624 LITE_INLINE pack(const type0& )
02625 {}
02626
02627 LITE_INLINE pack(
02628 const type0& ,
02629 const type1& a1,
02630 const type2& ,
02631 const type3& a3
02632 ) : i1(a1), i3(a3) {}
02633
02634 template<
02635 typename other_type0_ ,
02636 typename other_type1_ ,
02637 typename other_type2_ ,
02638 typename other_type3_
02639 >
02640 LITE_INLINE pack(const pack<
02641 other_type0_,
02642 other_type1_,
02643 other_type2_,
02644 other_type3_
02645 >& other) : i1(other.i1), i3(other.i3) {}
02646
02647 LITE_INLINE pack&
02648 operator= (const pack& other)
02649 {
02650 i1 = other.i1;
02651 i3 = other.i3;
02652 return *this;
02653 }
02654
02655 template<
02656 typename other_type0_ ,
02657 typename other_type1_ ,
02658 typename other_type2_ ,
02659 typename other_type3_
02660 >
02661 LITE_INLINE pack&
02662 operator=(const pack<
02663 other_type0_,
02664 other_type1_,
02665 other_type2_,
02666 other_type3_
02667 >& other)
02668 {
02669 i1 = other.i1;
02670 i3 = other.i3;
02671 return *this;
02672 }
02673
02674 LITE_INLINE void set(
02675 const type0& ,
02676 const type1& a1,
02677 const type2& ,
02678 const type3& a3
02679 )
02680 {
02681 i1 = a1;
02682 i3 = a3;
02683 }
02684 };
02685
02686
02687 template<
02688 typename type0_, type0_ value0_,
02689 typename type1_,
02690 typename type2_, type2_ value2_,
02691 typename type3_
02692 >
02693 const type0_ pack<
02694 constant<type0_, value0_>,
02695 type1_,
02696 constant<type2_, value2_>,
02697 type3_
02698 >::i0;
02699
02700 template<
02701 typename type0_, type0_ value0_,
02702 typename type1_,
02703 typename type2_, type2_ value2_,
02704 typename type3_
02705 >
02706 const type2_ pack<
02707 constant<type0_, value0_>,
02708 type1_,
02709 constant<type2_, value2_>,
02710 type3_
02711 >::i2;
02712
02713
02714 template<
02715 typename type0_,
02716 typename type1_, type1_ value1_,
02717 typename type2_, type2_ value2_,
02718 typename type3_
02719 >
02720 class pack<
02721 type0_,
02722 constant<type1_, value1_>,
02723 constant<type2_, value2_>,
02724 type3_
02725 >
02726 {
02727 public:
02728 static const int n = 4;
02729
02730 typedef type0_ type0;
02731 typedef type1_ type1;
02732 typedef type2_ type2;
02733 typedef type3_ type3;
02734
02735 static const bool is_const0 = false;
02736 static const bool is_const1 = true;
02737 static const bool is_const2 = true;
02738 static const bool is_const3 = false;
02739 static const bool is_all_const = false;
02740 type0 i0;
02741 static const type1 i1 = value1_;
02742 static const type2 i2 = value2_;
02743 type3 i3;
02744
02745 LITE_INLINE pack()
02746 : i0(),i3() {}
02747
02748 LITE_INLINE pack(const type0& a0)
02749 : i0(a0)
02750 {}
02751
02752 LITE_INLINE pack(
02753 const type0& a0,
02754 const type1& ,
02755 const type2& ,
02756 const type3& a3
02757 ) : i0(a0), i3(a3) {}
02758
02759 template<
02760 typename other_type0_ ,
02761 typename other_type1_ ,
02762 typename other_type2_ ,
02763 typename other_type3_
02764 >
02765 LITE_INLINE pack(const pack<
02766 other_type0_,
02767 other_type1_,
02768 other_type2_,
02769 other_type3_
02770 >& other) : i0(other.i0), i3(other.i3) {}
02771
02772 LITE_INLINE pack&
02773 operator= (const pack& other)
02774 {
02775 i0 = other.i0;
02776 i3 = other.i3;
02777 return *this;
02778 }
02779
02780 template<
02781 typename other_type0_ ,
02782 typename other_type1_ ,
02783 typename other_type2_ ,
02784 typename other_type3_
02785 >
02786 LITE_INLINE pack&
02787 operator=(const pack<
02788 other_type0_,
02789 other_type1_,
02790 other_type2_,
02791 other_type3_
02792 >& other)
02793 {
02794 i0 = other.i0;
02795 i3 = other.i3;
02796 return *this;
02797 }
02798
02799 LITE_INLINE void set(
02800 const type0& a0,
02801 const type1& ,
02802 const type2& ,
02803 const type3& a3
02804 )
02805 {
02806 i0 = a0;
02807 i3 = a3;
02808 }
02809 };
02810
02811
02812 template<
02813 typename type0_,
02814 typename type1_, type1_ value1_,
02815 typename type2_, type2_ value2_,
02816 typename type3_
02817 >
02818 const type1_ pack<
02819 type0_,
02820 constant<type1_, value1_>,
02821 constant<type2_, value2_>,
02822 type3_
02823 >::i1;
02824
02825 template<
02826 typename type0_,
02827 typename type1_, type1_ value1_,
02828 typename type2_, type2_ value2_,
02829 typename type3_
02830 >
02831 const type2_ pack<
02832 type0_,
02833 constant<type1_, value1_>,
02834 constant<type2_, value2_>,
02835 type3_
02836 >::i2;
02837
02838
02839 template<
02840 typename type0_, type0_ value0_,
02841 typename type1_, type1_ value1_,
02842 typename type2_, type2_ value2_,
02843 typename type3_
02844 >
02845 class pack<
02846 constant<type0_, value0_>,
02847 constant<type1_, value1_>,
02848 constant<type2_, value2_>,
02849 type3_
02850 >
02851 {
02852 public:
02853 static const int n = 4;
02854
02855 typedef type0_ type0;
02856 typedef type1_ type1;
02857 typedef type2_ type2;
02858 typedef type3_ type3;
02859
02860 static const bool is_const0 = true;
02861 static const bool is_const1 = true;
02862 static const bool is_const2 = true;
02863 static const bool is_const3 = false;
02864 static const bool is_all_const = false;
02865 static const type0 i0 = value0_;
02866 static const type1 i1 = value1_;
02867 static const type2 i2 = value2_;
02868 type3 i3;
02869
02870 LITE_INLINE pack()
02871 : i3() {}
02872
02873 LITE_INLINE pack(const type0& )
02874 {}
02875
02876 LITE_INLINE pack(
02877 const type0& ,
02878 const type1& ,
02879 const type2& ,
02880 const type3& a3
02881 ) : i3(a3) {}
02882
02883 template<
02884 typename other_type0_ ,
02885 typename other_type1_ ,
02886 typename other_type2_ ,
02887 typename other_type3_
02888 >
02889 LITE_INLINE pack(const pack<
02890 other_type0_,
02891 other_type1_,
02892 other_type2_,
02893 other_type3_
02894 >& other) : i3(other.i3) {}
02895
02896 LITE_INLINE pack&
02897 operator= (const pack& other)
02898 {
02899 i3 = other.i3;
02900 return *this;
02901 }
02902
02903 template<
02904 typename other_type0_ ,
02905 typename other_type1_ ,
02906 typename other_type2_ ,
02907 typename other_type3_
02908 >
02909 LITE_INLINE pack&
02910 operator=(const pack<
02911 other_type0_,
02912 other_type1_,
02913 other_type2_,
02914 other_type3_
02915 >& other)
02916 {
02917 i3 = other.i3;
02918 return *this;
02919 }
02920
02921 LITE_INLINE void set(
02922 const type0& ,
02923 const type1& ,
02924 const type2& ,
02925 const type3& a3
02926 )
02927 {
02928 i3 = a3;
02929 }
02930 };
02931
02932
02933 template<
02934 typename type0_, type0_ value0_,
02935 typename type1_, type1_ value1_,
02936 typename type2_, type2_ value2_,
02937 typename type3_
02938 >
02939 const type0_ pack<
02940 constant<type0_, value0_>,
02941 constant<type1_, value1_>,
02942 constant<type2_, value2_>,
02943 type3_
02944 >::i0;
02945
02946 template<
02947 typename type0_, type0_ value0_,
02948 typename type1_, type1_ value1_,
02949 typename type2_, type2_ value2_,
02950 typename type3_
02951 >
02952 const type1_ pack<
02953 constant<type0_, value0_>,
02954 constant<type1_, value1_>,
02955 constant<type2_, value2_>,
02956 type3_
02957 >::i1;
02958
02959 template<
02960 typename type0_, type0_ value0_,
02961 typename type1_, type1_ value1_,
02962 typename type2_, type2_ value2_,
02963 typename type3_
02964 >
02965 const type2_ pack<
02966 constant<type0_, value0_>,
02967 constant<type1_, value1_>,
02968 constant<type2_, value2_>,
02969 type3_
02970 >::i2;
02971
02972
02973 template<
02974 typename type0_,
02975 typename type1_,
02976 typename type2_,
02977 typename type3_, type3_ value3_
02978 >
02979 class pack<
02980 type0_,
02981 type1_,
02982 type2_,
02983 constant<type3_, value3_>
02984 >
02985 {
02986 public:
02987 static const int n = 4;
02988
02989 typedef type0_ type0;
02990 typedef type1_ type1;
02991 typedef type2_ type2;
02992 typedef type3_ type3;
02993
02994 static const bool is_const0 = false;
02995 static const bool is_const1 = false;
02996 static const bool is_const2 = false;
02997 static const bool is_const3 = true;
02998 static const bool is_all_const = false;
02999 type0 i0;
03000 type1 i1;
03001 type2 i2;
03002 static const type3 i3 = value3_;
03003
03004 LITE_INLINE pack()
03005 : i0(),i1(),i2() {}
03006
03007 LITE_INLINE pack(const type0& a0)
03008 : i0(a0)
03009 {}
03010
03011 LITE_INLINE pack(
03012 const type0& a0,
03013 const type1& a1,
03014 const type2& a2,
03015 const type3&
03016 ) : i0(a0), i1(a1), i2(a2) {}
03017
03018 template<
03019 typename other_type0_ ,
03020 typename other_type1_ ,
03021 typename other_type2_ ,
03022 typename other_type3_
03023 >
03024 LITE_INLINE pack(const pack<
03025 other_type0_,
03026 other_type1_,
03027 other_type2_,
03028 other_type3_
03029 >& other) : i0(other.i0), i1(other.i1), i2(other.i2) {}
03030
03031 LITE_INLINE pack&
03032 operator= (const pack& other)
03033 {
03034 i0 = other.i0;
03035 i1 = other.i1;
03036 i2 = other.i2;
03037 return *this;
03038 }
03039
03040 template<
03041 typename other_type0_ ,
03042 typename other_type1_ ,
03043 typename other_type2_ ,
03044 typename other_type3_
03045 >
03046 LITE_INLINE pack&
03047 operator=(const pack<
03048 other_type0_,
03049 other_type1_,
03050 other_type2_,
03051 other_type3_
03052 >& other)
03053 {
03054 i0 = other.i0;
03055 i1 = other.i1;
03056 i2 = other.i2;
03057 return *this;
03058 }
03059
03060 LITE_INLINE void set(
03061 const type0& a0,
03062 const type1& a1,
03063 const type2& a2,
03064 const type3&
03065 )
03066 {
03067 i0 = a0;
03068 i1 = a1;
03069 i2 = a2;
03070 }
03071 };
03072
03073
03074 template<
03075 typename type0_,
03076 typename type1_,
03077 typename type2_,
03078 typename type3_, type3_ value3_
03079 >
03080 const type3_ pack<
03081 type0_,
03082 type1_,
03083 type2_,
03084 constant<type3_, value3_>
03085 >::i3;
03086
03087
03088 template<
03089 typename type0_, type0_ value0_,
03090 typename type1_,
03091 typename type2_,
03092 typename type3_, type3_ value3_
03093 >
03094 class pack<
03095 constant<type0_, value0_>,
03096 type1_,
03097 type2_,
03098 constant<type3_, value3_>
03099 >
03100 {
03101 public:
03102 static const int n = 4;
03103
03104 typedef type0_ type0;
03105 typedef type1_ type1;
03106 typedef type2_ type2;
03107 typedef type3_ type3;
03108
03109 static const bool is_const0 = true;
03110 static const bool is_const1 = false;
03111 static const bool is_const2 = false;
03112 static const bool is_const3 = true;
03113 static const bool is_all_const = false;
03114 static const type0 i0 = value0_;
03115 type1 i1;
03116 type2 i2;
03117 static const type3 i3 = value3_;
03118
03119 LITE_INLINE pack()
03120 : i1(),i2() {}
03121
03122 LITE_INLINE pack(const type0& )
03123 {}
03124
03125 LITE_INLINE pack(
03126 const type0& ,
03127 const type1& a1,
03128 const type2& a2,
03129 const type3&
03130 ) : i1(a1), i2(a2) {}
03131
03132 template<
03133 typename other_type0_ ,
03134 typename other_type1_ ,
03135 typename other_type2_ ,
03136 typename other_type3_
03137 >
03138 LITE_INLINE pack(const pack<
03139 other_type0_,
03140 other_type1_,
03141 other_type2_,
03142 other_type3_
03143 >& other) : i1(other.i1), i2(other.i2) {}
03144
03145 LITE_INLINE pack&
03146 operator= (const pack& other)
03147 {
03148 i1 = other.i1;
03149 i2 = other.i2;
03150 return *this;
03151 }
03152
03153 template<
03154 typename other_type0_ ,
03155 typename other_type1_ ,
03156 typename other_type2_ ,
03157 typename other_type3_
03158 >
03159 LITE_INLINE pack&
03160 operator=(const pack<
03161 other_type0_,
03162 other_type1_,
03163 other_type2_,
03164 other_type3_
03165 >& other)
03166 {
03167 i1 = other.i1;
03168 i2 = other.i2;
03169 return *this;
03170 }
03171
03172 LITE_INLINE void set(
03173 const type0& ,
03174 const type1& a1,
03175 const type2& a2,
03176 const type3&
03177 )
03178 {
03179 i1 = a1;
03180 i2 = a2;
03181 }
03182 };
03183
03184
03185 template<
03186 typename type0_, type0_ value0_,
03187 typename type1_,
03188 typename type2_,
03189 typename type3_, type3_ value3_
03190 >
03191 const type0_ pack<
03192 constant<type0_, value0_>,
03193 type1_,
03194 type2_,
03195 constant<type3_, value3_>
03196 >::i0;
03197
03198 template<
03199 typename type0_, type0_ value0_,
03200 typename type1_,
03201 typename type2_,
03202 typename type3_, type3_ value3_
03203 >
03204 const type3_ pack<
03205 constant<type0_, value0_>,
03206 type1_,
03207 type2_,
03208 constant<type3_, value3_>
03209 >::i3;
03210
03211
03212 template<
03213 typename type0_,
03214 typename type1_, type1_ value1_,
03215 typename type2_,
03216 typename type3_, type3_ value3_
03217 >
03218 class pack<
03219 type0_,
03220 constant<type1_, value1_>,
03221 type2_,
03222 constant<type3_, value3_>
03223 >
03224 {
03225 public:
03226 static const int n = 4;
03227
03228 typedef type0_ type0;
03229 typedef type1_ type1;
03230 typedef type2_ type2;
03231 typedef type3_ type3;
03232
03233 static const bool is_const0 = false;
03234 static const bool is_const1 = true;
03235 static const bool is_const2 = false;
03236 static const bool is_const3 = true;
03237 static const bool is_all_const = false;
03238 type0 i0;
03239 static const type1 i1 = value1_;
03240 type2 i2;
03241 static const type3 i3 = value3_;
03242
03243 LITE_INLINE pack()
03244 : i0(),i2() {}
03245
03246 LITE_INLINE pack(const type0& a0)
03247 : i0(a0)
03248 {}
03249
03250 LITE_INLINE pack(
03251 const type0& a0,
03252 const type1& ,
03253 const type2& a2,
03254 const type3&
03255 ) : i0(a0), i2(a2) {}
03256
03257 template<
03258 typename other_type0_ ,
03259 typename other_type1_ ,
03260 typename other_type2_ ,
03261 typename other_type3_
03262 >
03263 LITE_INLINE pack(const pack<
03264 other_type0_,
03265 other_type1_,
03266 other_type2_,
03267 other_type3_
03268 >& other) : i0(other.i0), i2(other.i2) {}
03269
03270 LITE_INLINE pack&
03271 operator= (const pack& other)
03272 {
03273 i0 = other.i0;
03274 i2 = other.i2;
03275 return *this;
03276 }
03277
03278 template<
03279 typename other_type0_ ,
03280 typename other_type1_ ,
03281 typename other_type2_ ,
03282 typename other_type3_
03283 >
03284 LITE_INLINE pack&
03285 operator=(const pack<
03286 other_type0_,
03287 other_type1_,
03288 other_type2_,
03289 other_type3_
03290 >& other)
03291 {
03292 i0 = other.i0;
03293 i2 = other.i2;
03294 return *this;
03295 }
03296
03297 LITE_INLINE void set(
03298 const type0& a0,
03299 const type1& ,
03300 const type2& a2,
03301 const type3&
03302 )
03303 {
03304 i0 = a0;
03305 i2 = a2;
03306 }
03307 };
03308
03309
03310 template<
03311 typename type0_,
03312 typename type1_, type1_ value1_,
03313 typename type2_,
03314 typename type3_, type3_ value3_
03315 >
03316 const type1_ pack<
03317 type0_,
03318 constant<type1_, value1_>,
03319 type2_,
03320 constant<type3_, value3_>
03321 >::i1;
03322
03323 template<
03324 typename type0_,
03325 typename type1_, type1_ value1_,
03326 typename type2_,
03327 typename type3_, type3_ value3_
03328 >
03329 const type3_ pack<
03330 type0_,
03331 constant<type1_, value1_>,
03332 type2_,
03333 constant<type3_, value3_>
03334 >::i3;
03335
03336
03337 template<
03338 typename type0_, type0_ value0_,
03339 typename type1_, type1_ value1_,
03340 typename type2_,
03341 typename type3_, type3_ value3_
03342 >
03343 class pack<
03344 constant<type0_, value0_>,
03345 constant<type1_, value1_>,
03346 type2_,
03347 constant<type3_, value3_>
03348 >
03349 {
03350 public:
03351 static const int n = 4;
03352
03353 typedef type0_ type0;
03354 typedef type1_ type1;
03355 typedef type2_ type2;
03356 typedef type3_ type3;
03357
03358 static const bool is_const0 = true;
03359 static const bool is_const1 = true;
03360 static const bool is_const2 = false;
03361 static const bool is_const3 = true;
03362 static const bool is_all_const = false;
03363 static const type0 i0 = value0_;
03364 static const type1 i1 = value1_;
03365 type2 i2;
03366 static const type3 i3 = value3_;
03367
03368 LITE_INLINE pack()
03369 : i2() {}
03370
03371 LITE_INLINE pack(const type0& )
03372 {}
03373
03374 LITE_INLINE pack(
03375 const type0& ,
03376 const type1& ,
03377 const type2& a2,
03378 const type3&
03379 ) : i2(a2) {}
03380
03381 template<
03382 typename other_type0_ ,
03383 typename other_type1_ ,
03384 typename other_type2_ ,
03385 typename other_type3_
03386 >
03387 LITE_INLINE pack(const pack<
03388 other_type0_,
03389 other_type1_,
03390 other_type2_,
03391 other_type3_
03392 >& other) : i2(other.i2) {}
03393
03394 LITE_INLINE pack&
03395 operator= (const pack& other)
03396 {
03397 i2 = other.i2;
03398 return *this;
03399 }
03400
03401 template<
03402 typename other_type0_ ,
03403 typename other_type1_ ,
03404 typename other_type2_ ,
03405 typename other_type3_
03406 >
03407 LITE_INLINE pack&
03408 operator=(const pack<
03409 other_type0_,
03410 other_type1_,
03411 other_type2_,
03412 other_type3_
03413 >& other)
03414 {
03415 i2 = other.i2;
03416 return *this;
03417 }
03418
03419 LITE_INLINE void set(
03420 const type0& ,
03421 const type1& ,
03422 const type2& a2,
03423 const type3&
03424 )
03425 {
03426 i2 = a2;
03427 }
03428 };
03429
03430
03431 template<
03432 typename type0_, type0_ value0_,
03433 typename type1_, type1_ value1_,
03434 typename type2_,
03435 typename type3_, type3_ value3_
03436 >
03437 const type0_ pack<
03438 constant<type0_, value0_>,
03439 constant<type1_, value1_>,
03440 type2_,
03441 constant<type3_, value3_>
03442 >::i0;
03443
03444 template<
03445 typename type0_, type0_ value0_,
03446 typename type1_, type1_ value1_,
03447 typename type2_,
03448 typename type3_, type3_ value3_
03449 >
03450 const type1_ pack<
03451 constant<type0_, value0_>,
03452 constant<type1_, value1_>,
03453 type2_,
03454 constant<type3_, value3_>
03455 >::i1;
03456
03457 template<
03458 typename type0_, type0_ value0_,
03459 typename type1_, type1_ value1_,
03460 typename type2_,
03461 typename type3_, type3_ value3_
03462 >
03463 const type3_ pack<
03464 constant<type0_, value0_>,
03465 constant<type1_, value1_>,
03466 type2_,
03467 constant<type3_, value3_>
03468 >::i3;
03469
03470
03471 template<
03472 typename type0_,
03473 typename type1_,
03474 typename type2_, type2_ value2_,
03475 typename type3_, type3_ value3_
03476 >
03477 class pack<
03478 type0_,
03479 type1_,
03480 constant<type2_, value2_>,
03481 constant<type3_, value3_>
03482 >
03483 {
03484 public:
03485 static const int n = 4;
03486
03487 typedef type0_ type0;
03488 typedef type1_ type1;
03489 typedef type2_ type2;
03490 typedef type3_ type3;
03491
03492 static const bool is_const0 = false;
03493 static const bool is_const1 = false;
03494 static const bool is_const2 = true;
03495 static const bool is_const3 = true;
03496 static const bool is_all_const = false;
03497 type0 i0;
03498 type1 i1;
03499 static const type2 i2 = value2_;
03500 static const type3 i3 = value3_;
03501
03502 LITE_INLINE pack()
03503 : i0(),i1() {}
03504
03505 LITE_INLINE pack(const type0& a0)
03506 : i0(a0)
03507 {}
03508
03509 LITE_INLINE pack(
03510 const type0& a0,
03511 const type1& a1,
03512 const type2& ,
03513 const type3&
03514 ) : i0(a0), i1(a1) {}
03515
03516 template<
03517 typename other_type0_ ,
03518 typename other_type1_ ,
03519 typename other_type2_ ,
03520 typename other_type3_
03521 >
03522 LITE_INLINE pack(const pack<
03523 other_type0_,
03524 other_type1_,
03525 other_type2_,
03526 other_type3_
03527 >& other) : i0(other.i0), i1(other.i1) {}
03528
03529 LITE_INLINE pack&
03530 operator= (const pack& other)
03531 {
03532 i0 = other.i0;
03533 i1 = other.i1;
03534 return *this;
03535 }
03536
03537 template<
03538 typename other_type0_ ,
03539 typename other_type1_ ,
03540 typename other_type2_ ,
03541 typename other_type3_
03542 >
03543 LITE_INLINE pack&
03544 operator=(const pack<
03545 other_type0_,
03546 other_type1_,
03547 other_type2_,
03548 other_type3_
03549 >& other)
03550 {
03551 i0 = other.i0;
03552 i1 = other.i1;
03553 return *this;
03554 }
03555
03556 LITE_INLINE void set(
03557 const type0& a0,
03558 const type1& a1,
03559 const type2& ,
03560 const type3&
03561 )
03562 {
03563 i0 = a0;
03564 i1 = a1;
03565 }
03566 };
03567
03568
03569 template<
03570 typename type0_,
03571 typename type1_,
03572 typename type2_, type2_ value2_,
03573 typename type3_, type3_ value3_
03574 >
03575 const type2_ pack<
03576 type0_,
03577 type1_,
03578 constant<type2_, value2_>,
03579 constant<type3_, value3_>
03580 >::i2;
03581
03582 template<
03583 typename type0_,
03584 typename type1_,
03585 typename type2_, type2_ value2_,
03586 typename type3_, type3_ value3_
03587 >
03588 const type3_ pack<
03589 type0_,
03590 type1_,
03591 constant<type2_, value2_>,
03592 constant<type3_, value3_>
03593 >::i3;
03594
03595
03596 template<
03597 typename type0_, type0_ value0_,
03598 typename type1_,
03599 typename type2_, type2_ value2_,
03600 typename type3_, type3_ value3_
03601 >
03602 class pack<
03603 constant<type0_, value0_>,
03604 type1_,
03605 constant<type2_, value2_>,
03606 constant<type3_, value3_>
03607 >
03608 {
03609 public:
03610 static const int n = 4;
03611
03612 typedef type0_ type0;
03613 typedef type1_ type1;
03614 typedef type2_ type2;
03615 typedef type3_ type3;
03616
03617 static const bool is_const0 = true;
03618 static const bool is_const1 = false;
03619 static const bool is_const2 = true;
03620 static const bool is_const3 = true;
03621 static const bool is_all_const = false;
03622 static const type0 i0 = value0_;
03623 type1 i1;
03624 static const type2 i2 = value2_;
03625 static const type3 i3 = value3_;
03626
03627 LITE_INLINE pack()
03628 : i1() {}
03629
03630 LITE_INLINE pack(const type0& )
03631 {}
03632
03633 LITE_INLINE pack(
03634 const type0& ,
03635 const type1& a1,
03636 const type2& ,
03637 const type3&
03638 ) : i1(a1) {}
03639
03640 template<
03641 typename other_type0_ ,
03642 typename other_type1_ ,
03643 typename other_type2_ ,
03644 typename other_type3_
03645 >
03646 LITE_INLINE pack(const pack<
03647 other_type0_,
03648 other_type1_,
03649 other_type2_,
03650 other_type3_
03651 >& other) : i1(other.i1) {}
03652
03653 LITE_INLINE pack&
03654 operator= (const pack& other)
03655 {
03656 i1 = other.i1;
03657 return *this;
03658 }
03659
03660 template<
03661 typename other_type0_ ,
03662 typename other_type1_ ,
03663 typename other_type2_ ,
03664 typename other_type3_
03665 >
03666 LITE_INLINE pack&
03667 operator=(const pack<
03668 other_type0_,
03669 other_type1_,
03670 other_type2_,
03671 other_type3_
03672 >& other)
03673 {
03674 i1 = other.i1;
03675 return *this;
03676 }
03677
03678 LITE_INLINE void set(
03679 const type0& ,
03680 const type1& a1,
03681 const type2& ,
03682 const type3&
03683 )
03684 {
03685 i1 = a1;
03686 }
03687 };
03688
03689
03690 template<
03691 typename type0_, type0_ value0_,
03692 typename type1_,
03693 typename type2_, type2_ value2_,
03694 typename type3_, type3_ value3_
03695 >
03696 const type0_ pack<
03697 constant<type0_, value0_>,
03698 type1_,
03699 constant<type2_, value2_>,
03700 constant<type3_, value3_>
03701 >::i0;
03702
03703 template<
03704 typename type0_, type0_ value0_,
03705 typename type1_,
03706 typename type2_, type2_ value2_,
03707 typename type3_, type3_ value3_
03708 >
03709 const type2_ pack<
03710 constant<type0_, value0_>,
03711 type1_,
03712 constant<type2_, value2_>,
03713 constant<type3_, value3_>
03714 >::i2;
03715
03716 template<
03717 typename type0_, type0_ value0_,
03718 typename type1_,
03719 typename type2_, type2_ value2_,
03720 typename type3_, type3_ value3_
03721 >
03722 const type3_ pack<
03723 constant<type0_, value0_>,
03724 type1_,
03725 constant<type2_, value2_>,
03726 constant<type3_, value3_>
03727 >::i3;
03728
03729
03730 template<
03731 typename type0_,
03732 typename type1_, type1_ value1_,
03733 typename type2_, type2_ value2_,
03734 typename type3_, type3_ value3_
03735 >
03736 class pack<
03737 type0_,
03738 constant<type1_, value1_>,
03739 constant<type2_, value2_>,
03740 constant<type3_, value3_>
03741 >
03742 {
03743 public:
03744 static const int n = 4;
03745
03746 typedef type0_ type0;
03747 typedef type1_ type1;
03748 typedef type2_ type2;
03749 typedef type3_ type3;
03750
03751 static const bool is_const0 = false;
03752 static const bool is_const1 = true;
03753 static const bool is_const2 = true;
03754 static const bool is_const3 = true;
03755 static const bool is_all_const = false;
03756 type0 i0;
03757 static const type1 i1 = value1_;
03758 static const type2 i2 = value2_;
03759 static const type3 i3 = value3_;
03760
03761 LITE_INLINE pack()
03762 : i0() {}
03763
03764 LITE_INLINE pack(const type0& a0)
03765 : i0(a0)
03766 {}
03767
03768 LITE_INLINE pack(
03769 const type0& a0,
03770 const type1& ,
03771 const type2& ,
03772 const type3&
03773 ) : i0(a0) {}
03774
03775 template<
03776 typename other_type0_ ,
03777 typename other_type1_ ,
03778 typename other_type2_ ,
03779 typename other_type3_
03780 >
03781 LITE_INLINE pack(const pack<
03782 other_type0_,
03783 other_type1_,
03784 other_type2_,
03785 other_type3_
03786 >& other) : i0(other.i0) {}
03787
03788 LITE_INLINE pack&
03789 operator= (const pack& other)
03790 {
03791 i0 = other.i0;
03792 return *this;
03793 }
03794
03795 template<
03796 typename other_type0_ ,
03797 typename other_type1_ ,
03798 typename other_type2_ ,
03799 typename other_type3_
03800 >
03801 LITE_INLINE pack&
03802 operator=(const pack<
03803 other_type0_,
03804 other_type1_,
03805 other_type2_,
03806 other_type3_
03807 >& other)
03808 {
03809 i0 = other.i0;
03810 return *this;
03811 }
03812
03813 LITE_INLINE void set(
03814 const type0& a0,
03815 const type1& ,
03816 const type2& ,
03817 const type3&
03818 )
03819 {
03820 i0 = a0;
03821 }
03822 };
03823
03824
03825 template<
03826 typename type0_,
03827 typename type1_, type1_ value1_,
03828 typename type2_, type2_ value2_,
03829 typename type3_, type3_ value3_
03830 >
03831 const type1_ pack<
03832 type0_,
03833 constant<type1_, value1_>,
03834 constant<type2_, value2_>,
03835 constant<type3_, value3_>
03836 >::i1;
03837
03838 template<
03839 typename type0_,
03840 typename type1_, type1_ value1_,
03841 typename type2_, type2_ value2_,
03842 typename type3_, type3_ value3_
03843 >
03844 const type2_ pack<
03845 type0_,
03846 constant<type1_, value1_>,
03847 constant<type2_, value2_>,
03848 constant<type3_, value3_>
03849 >::i2;
03850
03851 template<
03852 typename type0_,
03853 typename type1_, type1_ value1_,
03854 typename type2_, type2_ value2_,
03855 typename type3_, type3_ value3_
03856 >
03857 const type3_ pack<
03858 type0_,
03859 constant<type1_, value1_>,
03860 constant<type2_, value2_>,
03861 constant<type3_, value3_>
03862 >::i3;
03863
03864
03865 template<
03866 typename type0_, type0_ value0_,
03867 typename type1_, type1_ value1_,
03868 typename type2_, type2_ value2_,
03869 typename type3_, type3_ value3_
03870 >
03871 class pack<
03872 constant<type0_, value0_>,
03873 constant<type1_, value1_>,
03874 constant<type2_, value2_>,
03875 constant<type3_, value3_>
03876 >
03877 {
03878 public:
03879 static const int n = 4;
03880
03881 typedef type0_ type0;
03882 typedef type1_ type1;
03883 typedef type2_ type2;
03884 typedef type3_ type3;
03885
03886 static const bool is_const0 = true;
03887 static const bool is_const1 = true;
03888 static const bool is_const2 = true;
03889 static const bool is_const3 = true;
03890 static const bool is_all_const = true;
03891 static const type0 i0 = value0_;
03892 static const type1 i1 = value1_;
03893 static const type2 i2 = value2_;
03894 static const type3 i3 = value3_;
03895
03896 LITE_INLINE pack()
03897 {}
03898
03899 LITE_INLINE pack(const type0& )
03900 {}
03901
03902 LITE_INLINE pack(
03903 const type0& ,
03904 const type1& ,
03905 const type2& ,
03906 const type3&
03907 ) {}
03908
03909 template<
03910 typename other_type0_ ,
03911 typename other_type1_ ,
03912 typename other_type2_ ,
03913 typename other_type3_
03914 >
03915 LITE_INLINE pack(const pack<
03916 other_type0_,
03917 other_type1_,
03918 other_type2_,
03919 other_type3_
03920 >& ) {}
03921
03922 LITE_INLINE pack&
03923 operator= (const pack& )
03924 {
03925 return *this;
03926 }
03927
03928 template<
03929 typename other_type0_ ,
03930 typename other_type1_ ,
03931 typename other_type2_ ,
03932 typename other_type3_
03933 >
03934 LITE_INLINE pack&
03935 operator=(const pack<
03936 other_type0_,
03937 other_type1_,
03938 other_type2_,
03939 other_type3_
03940 >& )
03941 {
03942 return *this;
03943 }
03944
03945 LITE_INLINE void set(
03946 const type0& ,
03947 const type1& ,
03948 const type2& ,
03949 const type3&
03950 )
03951 {
03952 }
03953 };
03954
03955
03956 template<
03957 typename type0_, type0_ value0_,
03958 typename type1_, type1_ value1_,
03959 typename type2_, type2_ value2_,
03960 typename type3_, type3_ value3_
03961 >
03962 const type0_ pack<
03963 constant<type0_, value0_>,
03964 constant<type1_, value1_>,
03965 constant<type2_, value2_>,
03966 constant<type3_, value3_>
03967 >::i0;
03968
03969 template<
03970 typename type0_, type0_ value0_,
03971 typename type1_, type1_ value1_,
03972 typename type2_, type2_ value2_,
03973 typename type3_, type3_ value3_
03974 >
03975 const type1_ pack<
03976 constant<type0_, value0_>,
03977 constant<type1_, value1_>,
03978 constant<type2_, value2_>,
03979 constant<type3_, value3_>
03980 >::i1;
03981
03982 template<
03983 typename type0_, type0_ value0_,
03984 typename type1_, type1_ value1_,
03985 typename type2_, type2_ value2_,
03986 typename type3_, type3_ value3_
03987 >
03988 const type2_ pack<
03989 constant<type0_, value0_>,
03990 constant<type1_, value1_>,
03991 constant<type2_, value2_>,
03992 constant<type3_, value3_>
03993 >::i2;
03994
03995 template<
03996 typename type0_, type0_ value0_,
03997 typename type1_, type1_ value1_,
03998 typename type2_, type2_ value2_,
03999 typename type3_, type3_ value3_
04000 >
04001 const type3_ pack<
04002 constant<type0_, value0_>,
04003 constant<type1_, value1_>,
04004 constant<type2_, value2_>,
04005 constant<type3_, value3_>
04006 >::i3;
04007
04008
04009 template<
04010 typename type0_,
04011 typename type1_,
04012 typename type2_
04013 >
04014 class pack<
04015 type0_,
04016 type1_,
04017 type2_
04018 >
04019 {
04020 public:
04021 static const int n = 3;
04022
04023 typedef type0_ type0;
04024 typedef type1_ type1;
04025 typedef type2_ type2;
04026
04027 static const bool is_const0 = false;
04028 static const bool is_const1 = false;
04029 static const bool is_const2 = false;
04030 static const bool is_all_const = false;
04031 type0 i0;
04032 type1 i1;
04033 type2 i2;
04034
04035 LITE_INLINE pack()
04036 : i0(),i1(),i2() {}
04037
04038 LITE_INLINE pack(const type0& a0)
04039 : i0(a0)
04040 {}
04041
04042 LITE_INLINE pack(
04043 const type0& a0,
04044 const type1& a1,
04045 const type2& a2
04046 ) : i0(a0), i1(a1), i2(a2) {}
04047
04048 template<
04049 typename other_type0_ ,
04050 typename other_type1_ ,
04051 typename other_type2_
04052 >
04053 LITE_INLINE pack(const pack<
04054 other_type0_,
04055 other_type1_,
04056 other_type2_
04057 >& other) : i0(other.i0), i1(other.i1), i2(other.i2) {}
04058
04059 LITE_INLINE pack&
04060 operator= (const pack& other)
04061 {
04062 i0 = other.i0;
04063 i1 = other.i1;
04064 i2 = other.i2;
04065 return *this;
04066 }
04067
04068 template<
04069 typename other_type0_ ,
04070 typename other_type1_ ,
04071 typename other_type2_
04072 >
04073 LITE_INLINE pack&
04074 operator=(const pack<
04075 other_type0_,
04076 other_type1_,
04077 other_type2_
04078 >& other)
04079 {
04080 i0 = other.i0;
04081 i1 = other.i1;
04082 i2 = other.i2;
04083 return *this;
04084 }
04085
04086 LITE_INLINE void set(
04087 const type0& a0,
04088 const type1& a1,
04089 const type2& a2
04090 )
04091 {
04092 i0 = a0;
04093 i1 = a1;
04094 i2 = a2;
04095 }
04096 };
04097
04098
04099
04100 template<
04101 typename type0_, type0_ value0_,
04102 typename type1_,
04103 typename type2_
04104 >
04105 class pack<
04106 constant<type0_, value0_>,
04107 type1_,
04108 type2_
04109 >
04110 {
04111 public:
04112 static const int n = 3;
04113
04114 typedef type0_ type0;
04115 typedef type1_ type1;
04116 typedef type2_ type2;
04117
04118 static const bool is_const0 = true;
04119 static const bool is_const1 = false;
04120 static const bool is_const2 = false;
04121 static const bool is_all_const = false;
04122 static const type0 i0 = value0_;
04123 type1 i1;
04124 type2 i2;
04125
04126 LITE_INLINE pack()
04127 : i1(),i2() {}
04128
04129 LITE_INLINE pack(const type0& )
04130 {}
04131
04132 LITE_INLINE pack(
04133 const type0& ,
04134 const type1& a1,
04135 const type2& a2
04136 ) : i1(a1), i2(a2) {}
04137
04138 template<
04139 typename other_type0_ ,
04140 typename other_type1_ ,
04141 typename other_type2_
04142 >
04143 LITE_INLINE pack(const pack<
04144 other_type0_,
04145 other_type1_,
04146 other_type2_
04147 >& other) : i1(other.i1), i2(other.i2) {}
04148
04149 LITE_INLINE pack&
04150 operator= (const pack& other)
04151 {
04152 i1 = other.i1;
04153 i2 = other.i2;
04154 return *this;
04155 }
04156
04157 template<
04158 typename other_type0_ ,
04159 typename other_type1_ ,
04160 typename other_type2_
04161 >
04162 LITE_INLINE pack&
04163 operator=(const pack<
04164 other_type0_,
04165 other_type1_,
04166 other_type2_
04167 >& other)
04168 {
04169 i1 = other.i1;
04170 i2 = other.i2;
04171 return *this;
04172 }
04173
04174 LITE_INLINE void set(
04175 const type0& ,
04176 const type1& a1,
04177 const type2& a2
04178 )
04179 {
04180 i1 = a1;
04181 i2 = a2;
04182 }
04183 };
04184
04185
04186 template<
04187 typename type0_, type0_ value0_,
04188 typename type1_,
04189 typename type2_
04190 >
04191 const type0_ pack<
04192 constant<type0_, value0_>,
04193 type1_,
04194 type2_
04195 >::i0;
04196
04197
04198 template<
04199 typename type0_,
04200 typename type1_, type1_ value1_,
04201 typename type2_
04202 >
04203 class pack<
04204 type0_,
04205 constant<type1_, value1_>,
04206 type2_
04207 >
04208 {
04209 public:
04210 static const int n = 3;
04211
04212 typedef type0_ type0;
04213 typedef type1_ type1;
04214 typedef type2_ type2;
04215
04216 static const bool is_const0 = false;
04217 static const bool is_const1 = true;
04218 static const bool is_const2 = false;
04219 static const bool is_all_const = false;
04220 type0 i0;
04221 static const type1 i1 = value1_;
04222 type2 i2;
04223
04224 LITE_INLINE pack()
04225 : i0(),i2() {}
04226
04227 LITE_INLINE pack(const type0& a0)
04228 : i0(a0)
04229 {}
04230
04231 LITE_INLINE pack(
04232 const type0& a0,
04233 const type1& ,
04234 const type2& a2
04235 ) : i0(a0), i2(a2) {}
04236
04237 template<
04238 typename other_type0_ ,
04239 typename other_type1_ ,
04240 typename other_type2_
04241 >
04242 LITE_INLINE pack(const pack<
04243 other_type0_,
04244 other_type1_,
04245 other_type2_
04246 >& other) : i0(other.i0), i2(other.i2) {}
04247
04248 LITE_INLINE pack&
04249 operator= (const pack& other)
04250 {
04251 i0 = other.i0;
04252 i2 = other.i2;
04253 return *this;
04254 }
04255
04256 template<
04257 typename other_type0_ ,
04258 typename other_type1_ ,
04259 typename other_type2_
04260 >
04261 LITE_INLINE pack&
04262 operator=(const pack<
04263 other_type0_,
04264 other_type1_,
04265 other_type2_
04266 >& other)
04267 {
04268 i0 = other.i0;
04269 i2 = other.i2;
04270 return *this;
04271 }
04272
04273 LITE_INLINE void set(
04274 const type0& a0,
04275 const type1& ,
04276 const type2& a2
04277 )
04278 {
04279 i0 = a0;
04280 i2 = a2;
04281 }
04282 };
04283
04284
04285 template<
04286 typename type0_,
04287 typename type1_, type1_ value1_,
04288 typename type2_
04289 >
04290 const type1_ pack<
04291 type0_,
04292 constant<type1_, value1_>,
04293 type2_
04294 >::i1;
04295
04296
04297 template<
04298 typename type0_, type0_ value0_,
04299 typename type1_, type1_ value1_,
04300 typename type2_
04301 >
04302 class pack<
04303 constant<type0_, value0_>,
04304 constant<type1_, value1_>,
04305 type2_
04306 >
04307 {
04308 public:
04309 static const int n = 3;
04310
04311 typedef type0_ type0;
04312 typedef type1_ type1;
04313 typedef type2_ type2;
04314
04315 static const bool is_const0 = true;
04316 static const bool is_const1 = true;
04317 static const bool is_const2 = false;
04318 static const bool is_all_const = false;
04319 static const type0 i0 = value0_;
04320 static const type1 i1 = value1_;
04321 type2 i2;
04322
04323 LITE_INLINE pack()
04324 : i2() {}
04325
04326 LITE_INLINE pack(const type0& )
04327 {}
04328
04329 LITE_INLINE pack(
04330 const type0& ,
04331 const type1& ,
04332 const type2& a2
04333 ) : i2(a2) {}
04334
04335 template<
04336 typename other_type0_ ,
04337 typename other_type1_ ,
04338 typename other_type2_
04339 >
04340 LITE_INLINE pack(const pack<
04341 other_type0_,
04342 other_type1_,
04343 other_type2_
04344 >& other) : i2(other.i2) {}
04345
04346 LITE_INLINE pack&
04347 operator= (const pack& other)
04348 {
04349 i2 = other.i2;
04350 return *this;
04351 }
04352
04353 template<
04354 typename other_type0_ ,
04355 typename other_type1_ ,
04356 typename other_type2_
04357 >
04358 LITE_INLINE pack&
04359 operator=(const pack<
04360 other_type0_,
04361 other_type1_,
04362 other_type2_
04363 >& other)
04364 {
04365 i2 = other.i2;
04366 return *this;
04367 }
04368
04369 LITE_INLINE void set(
04370 const type0& ,
04371 const type1& ,
04372 const type2& a2
04373 )
04374 {
04375 i2 = a2;
04376 }
04377 };
04378
04379
04380 template<
04381 typename type0_, type0_ value0_,
04382 typename type1_, type1_ value1_,
04383 typename type2_
04384 >
04385 const type0_ pack<
04386 constant<type0_, value0_>,
04387 constant<type1_, value1_>,
04388 type2_
04389 >::i0;
04390
04391 template<
04392 typename type0_, type0_ value0_,
04393 typename type1_, type1_ value1_,
04394 typename type2_
04395 >
04396 const type1_ pack<
04397 constant<type0_, value0_>,
04398 constant<type1_, value1_>,
04399 type2_
04400 >::i1;
04401
04402
04403 template<
04404 typename type0_,
04405 typename type1_,
04406 typename type2_, type2_ value2_
04407 >
04408 class pack<
04409 type0_,
04410 type1_,
04411 constant<type2_, value2_>
04412 >
04413 {
04414 public:
04415 static const int n = 3;
04416
04417 typedef type0_ type0;
04418 typedef type1_ type1;
04419 typedef type2_ type2;
04420
04421 static const bool is_const0 = false;
04422 static const bool is_const1 = false;
04423 static const bool is_const2 = true;
04424 static const bool is_all_const = false;
04425 type0 i0;
04426 type1 i1;
04427 static const type2 i2 = value2_;
04428
04429 LITE_INLINE pack()
04430 : i0(),i1() {}
04431
04432 LITE_INLINE pack(const type0& a0)
04433 : i0(a0)
04434 {}
04435
04436 LITE_INLINE pack(
04437 const type0& a0,
04438 const type1& a1,
04439 const type2&
04440 ) : i0(a0), i1(a1) {}
04441
04442 template<
04443 typename other_type0_ ,
04444 typename other_type1_ ,
04445 typename other_type2_
04446 >
04447 LITE_INLINE pack(const pack<
04448 other_type0_,
04449 other_type1_,
04450 other_type2_
04451 >& other) : i0(other.i0), i1(other.i1) {}
04452
04453 LITE_INLINE pack&
04454 operator= (const pack& other)
04455 {
04456 i0 = other.i0;
04457 i1 = other.i1;
04458 return *this;
04459 }
04460
04461 template<
04462 typename other_type0_ ,
04463 typename other_type1_ ,
04464 typename other_type2_
04465 >
04466 LITE_INLINE pack&
04467 operator=(const pack<
04468 other_type0_,
04469 other_type1_,
04470 other_type2_
04471 >& other)
04472 {
04473 i0 = other.i0;
04474 i1 = other.i1;
04475 return *this;
04476 }
04477
04478 LITE_INLINE void set(
04479 const type0& a0,
04480 const type1& a1,
04481 const type2&
04482 )
04483 {
04484 i0 = a0;
04485 i1 = a1;
04486 }
04487 };
04488
04489
04490 template<
04491 typename type0_,
04492 typename type1_,
04493 typename type2_, type2_ value2_
04494 >
04495 const type2_ pack<
04496 type0_,
04497 type1_,
04498 constant<type2_, value2_>
04499 >::i2;
04500
04501
04502 template<
04503 typename type0_, type0_ value0_,
04504 typename type1_,
04505 typename type2_, type2_ value2_
04506 >
04507 class pack<
04508 constant<type0_, value0_>,
04509 type1_,
04510 constant<type2_, value2_>
04511 >
04512 {
04513 public:
04514 static const int n = 3;
04515
04516 typedef type0_ type0;
04517 typedef type1_ type1;
04518 typedef type2_ type2;
04519
04520 static const bool is_const0 = true;
04521 static const bool is_const1 = false;
04522 static const bool is_const2 = true;
04523 static const bool is_all_const = false;
04524 static const type0 i0 = value0_;
04525 type1 i1;
04526 static const type2 i2 = value2_;
04527
04528 LITE_INLINE pack()
04529 : i1() {}
04530
04531 LITE_INLINE pack(const type0& )
04532 {}
04533
04534 LITE_INLINE pack(
04535 const type0& ,
04536 const type1& a1,
04537 const type2&
04538 ) : i1(a1) {}
04539
04540 template<
04541 typename other_type0_ ,
04542 typename other_type1_ ,
04543 typename other_type2_
04544 >
04545 LITE_INLINE pack(const pack<
04546 other_type0_,
04547 other_type1_,
04548 other_type2_
04549 >& other) : i1(other.i1) {}
04550
04551 LITE_INLINE pack&
04552 operator= (const pack& other)
04553 {
04554 i1 = other.i1;
04555 return *this;
04556 }
04557
04558 template<
04559 typename other_type0_ ,
04560 typename other_type1_ ,
04561 typename other_type2_
04562 >
04563 LITE_INLINE pack&
04564 operator=(const pack<
04565 other_type0_,
04566 other_type1_,
04567 other_type2_
04568 >& other)
04569 {
04570 i1 = other.i1;
04571 return *this;
04572 }
04573
04574 LITE_INLINE void set(
04575 const type0& ,
04576 const type1& a1,
04577 const type2&
04578 )
04579 {
04580 i1 = a1;
04581 }
04582 };
04583
04584
04585 template<
04586 typename type0_, type0_ value0_,
04587 typename type1_,
04588 typename type2_, type2_ value2_
04589 >
04590 const type0_ pack<
04591 constant<type0_, value0_>,
04592 type1_,
04593 constant<type2_, value2_>
04594 >::i0;
04595
04596 template<
04597 typename type0_, type0_ value0_,
04598 typename type1_,
04599 typename type2_, type2_ value2_
04600 >
04601 const type2_ pack<
04602 constant<type0_, value0_>,
04603 type1_,
04604 constant<type2_, value2_>
04605 >::i2;
04606
04607
04608 template<
04609 typename type0_,
04610 typename type1_, type1_ value1_,
04611 typename type2_, type2_ value2_
04612 >
04613 class pack<
04614 type0_,
04615 constant<type1_, value1_>,
04616 constant<type2_, value2_>
04617 >
04618 {
04619 public:
04620 static const int n = 3;
04621
04622 typedef type0_ type0;
04623 typedef type1_ type1;
04624 typedef type2_ type2;
04625
04626 static const bool is_const0 = false;
04627 static const bool is_const1 = true;
04628 static const bool is_const2 = true;
04629 static const bool is_all_const = false;
04630 type0 i0;
04631 static const type1 i1 = value1_;
04632 static const type2 i2 = value2_;
04633
04634 LITE_INLINE pack()
04635 : i0() {}
04636
04637 LITE_INLINE pack(const type0& a0)
04638 : i0(a0)
04639 {}
04640
04641 LITE_INLINE pack(
04642 const type0& a0,
04643 const type1& ,
04644 const type2&
04645 ) : i0(a0) {}
04646
04647 template<
04648 typename other_type0_ ,
04649 typename other_type1_ ,
04650 typename other_type2_
04651 >
04652 LITE_INLINE pack(const pack<
04653 other_type0_,
04654 other_type1_,
04655 other_type2_
04656 >& other) : i0(other.i0) {}
04657
04658 LITE_INLINE pack&
04659 operator= (const pack& other)
04660 {
04661 i0 = other.i0;
04662 return *this;
04663 }
04664
04665 template<
04666 typename other_type0_ ,
04667 typename other_type1_ ,
04668 typename other_type2_
04669 >
04670 LITE_INLINE pack&
04671 operator=(const pack<
04672 other_type0_,
04673 other_type1_,
04674 other_type2_
04675 >& other)
04676 {
04677 i0 = other.i0;
04678 return *this;
04679 }
04680
04681 LITE_INLINE void set(
04682 const type0& a0,
04683 const type1& ,
04684 const type2&
04685 )
04686 {
04687 i0 = a0;
04688 }
04689 };
04690
04691
04692 template<
04693 typename type0_,
04694 typename type1_, type1_ value1_,
04695 typename type2_, type2_ value2_
04696 >
04697 const type1_ pack<
04698 type0_,
04699 constant<type1_, value1_>,
04700 constant<type2_, value2_>
04701 >::i1;
04702
04703 template<
04704 typename type0_,
04705 typename type1_, type1_ value1_,
04706 typename type2_, type2_ value2_
04707 >
04708 const type2_ pack<
04709 type0_,
04710 constant<type1_, value1_>,
04711 constant<type2_, value2_>
04712 >::i2;
04713
04714
04715 template<
04716 typename type0_, type0_ value0_,
04717 typename type1_, type1_ value1_,
04718 typename type2_, type2_ value2_
04719 >
04720 class pack<
04721 constant<type0_, value0_>,
04722 constant<type1_, value1_>,
04723 constant<type2_, value2_>
04724 >
04725 {
04726 public:
04727 static const int n = 3;
04728
04729 typedef type0_ type0;
04730 typedef type1_ type1;
04731 typedef type2_ type2;
04732
04733 static const bool is_const0 = true;
04734 static const bool is_const1 = true;
04735 static const bool is_const2 = true;
04736 static const bool is_all_const = true;
04737 static const type0 i0 = value0_;
04738 static const type1 i1 = value1_;
04739 static const type2 i2 = value2_;
04740
04741 LITE_INLINE pack()
04742 {}
04743
04744 LITE_INLINE pack(const type0& )
04745 {}
04746
04747 LITE_INLINE pack(
04748 const type0& ,
04749 const type1& ,
04750 const type2&
04751 ) {}
04752
04753 template<
04754 typename other_type0_ ,
04755 typename other_type1_ ,
04756 typename other_type2_
04757 >
04758 LITE_INLINE pack(const pack<
04759 other_type0_,
04760 other_type1_,
04761 other_type2_
04762 >& ) {}
04763
04764 LITE_INLINE pack&
04765 operator= (const pack& )
04766 {
04767 return *this;
04768 }
04769
04770 template<
04771 typename other_type0_ ,
04772 typename other_type1_ ,
04773 typename other_type2_
04774 >
04775 LITE_INLINE pack&
04776 operator=(const pack<
04777 other_type0_,
04778 other_type1_,
04779 other_type2_
04780 >& )
04781 {
04782 return *this;
04783 }
04784
04785 LITE_INLINE void set(
04786 const type0& ,
04787 const type1& ,
04788 const type2&
04789 )
04790 {
04791 }
04792 };
04793
04794
04795 template<
04796 typename type0_, type0_ value0_,
04797 typename type1_, type1_ value1_,
04798 typename type2_, type2_ value2_
04799 >
04800 const type0_ pack<
04801 constant<type0_, value0_>,
04802 constant<type1_, value1_>,
04803 constant<type2_, value2_>
04804 >::i0;
04805
04806 template<
04807 typename type0_, type0_ value0_,
04808 typename type1_, type1_ value1_,
04809 typename type2_, type2_ value2_
04810 >
04811 const type1_ pack<
04812 constant<type0_, value0_>,
04813 constant<type1_, value1_>,
04814 constant<type2_, value2_>
04815 >::i1;
04816
04817 template<
04818 typename type0_, type0_ value0_,
04819 typename type1_, type1_ value1_,
04820 typename type2_, type2_ value2_
04821 >
04822 const type2_ pack<
04823 constant<type0_, value0_>,
04824 constant<type1_, value1_>,
04825 constant<type2_, value2_>
04826 >::i2;
04827
04828
04829 template<
04830 typename type0_,
04831 typename type1_
04832 >
04833 class pack<
04834 type0_,
04835 type1_
04836 >
04837 {
04838 public:
04839 static const int n = 2;
04840
04841 typedef type0_ type0;
04842 typedef type1_ type1;
04843
04844 static const bool is_const0 = false;
04845 static const bool is_const1 = false;
04846 static const bool is_all_const = false;
04847 type0 i0;
04848 type1 i1;
04849
04850 LITE_INLINE pack()
04851 : i0(),i1() {}
04852
04853 LITE_INLINE pack(const type0& a0)
04854 : i0(a0)
04855 {}
04856
04857 LITE_INLINE pack(
04858 const type0& a0,
04859 const type1& a1
04860 ) : i0(a0), i1(a1) {}
04861
04862 template<
04863 typename other_type0_ ,
04864 typename other_type1_
04865 >
04866 LITE_INLINE pack(const pack<
04867 other_type0_,
04868 other_type1_
04869 >& other) : i0(other.i0), i1(other.i1) {}
04870
04871 LITE_INLINE pack&
04872 operator= (const pack& other)
04873 {
04874 i0 = other.i0;
04875 i1 = other.i1;
04876 return *this;
04877 }
04878
04879 template<
04880 typename other_type0_ ,
04881 typename other_type1_
04882 >
04883 LITE_INLINE pack&
04884 operator=(const pack<
04885 other_type0_,
04886 other_type1_
04887 >& other)
04888 {
04889 i0 = other.i0;
04890 i1 = other.i1;
04891 return *this;
04892 }
04893
04894 LITE_INLINE void set(
04895 const type0& a0,
04896 const type1& a1
04897 )
04898 {
04899 i0 = a0;
04900 i1 = a1;
04901 }
04902 };
04903
04904
04905
04906 template<
04907 typename type0_, type0_ value0_,
04908 typename type1_
04909 >
04910 class pack<
04911 constant<type0_, value0_>,
04912 type1_
04913 >
04914 {
04915 public:
04916 static const int n = 2;
04917
04918 typedef type0_ type0;
04919 typedef type1_ type1;
04920
04921 static const bool is_const0 = true;
04922 static const bool is_const1 = false;
04923 static const bool is_all_const = false;
04924 static const type0 i0 = value0_;
04925 type1 i1;
04926
04927 LITE_INLINE pack()
04928 : i1() {}
04929
04930 LITE_INLINE pack(const type0& )
04931 {}
04932
04933 LITE_INLINE pack(
04934 const type0& ,
04935 const type1& a1
04936 ) : i1(a1) {}
04937
04938 template<
04939 typename other_type0_ ,
04940 typename other_type1_
04941 >
04942 LITE_INLINE pack(const pack<
04943 other_type0_,
04944 other_type1_
04945 >& other) : i1(other.i1) {}
04946
04947 LITE_INLINE pack&
04948 operator= (const pack& other)
04949 {
04950 i1 = other.i1;
04951 return *this;
04952 }
04953
04954 template<
04955 typename other_type0_ ,
04956 typename other_type1_
04957 >
04958 LITE_INLINE pack&
04959 operator=(const pack<
04960 other_type0_,
04961 other_type1_
04962 >& other)
04963 {
04964 i1 = other.i1;
04965 return *this;
04966 }
04967
04968 LITE_INLINE void set(
04969 const type0& ,
04970 const type1& a1
04971 )
04972 {
04973 i1 = a1;
04974 }
04975 };
04976
04977
04978 template<
04979 typename type0_, type0_ value0_,
04980 typename type1_
04981 >
04982 const type0_ pack<
04983 constant<type0_, value0_>,
04984 type1_
04985 >::i0;
04986
04987
04988 template<
04989 typename type0_,
04990 typename type1_, type1_ value1_
04991 >
04992 class pack<
04993 type0_,
04994 constant<type1_, value1_>
04995 >
04996 {
04997 public:
04998 static const int n = 2;
04999
05000 typedef type0_ type0;
05001 typedef type1_ type1;
05002
05003 static const bool is_const0 = false;
05004 static const bool is_const1 = true;
05005 static const bool is_all_const = false;
05006 type0 i0;
05007 static const type1 i1 = value1_;
05008
05009 LITE_INLINE pack()
05010 : i0() {}
05011
05012 LITE_INLINE pack(const type0& a0)
05013 : i0(a0)
05014 {}
05015
05016 LITE_INLINE pack(
05017 const type0& a0,
05018 const type1&
05019 ) : i0(a0) {}
05020
05021 template<
05022 typename other_type0_ ,
05023 typename other_type1_
05024 >
05025 LITE_INLINE pack(const pack<
05026 other_type0_,
05027 other_type1_
05028 >& other) : i0(other.i0) {}
05029
05030 LITE_INLINE pack&
05031 operator= (const pack& other)
05032 {
05033 i0 = other.i0;
05034 return *this;
05035 }
05036
05037 template<
05038 typename other_type0_ ,
05039 typename other_type1_
05040 >
05041 LITE_INLINE pack&
05042 operator=(const pack<
05043 other_type0_,
05044 other_type1_
05045 >& other)
05046 {
05047 i0 = other.i0;
05048 return *this;
05049 }
05050
05051 LITE_INLINE void set(
05052 const type0& a0,
05053 const type1&
05054 )
05055 {
05056 i0 = a0;
05057 }
05058 };
05059
05060
05061 template<
05062 typename type0_,
05063 typename type1_, type1_ value1_
05064 >
05065 const type1_ pack<
05066 type0_,
05067 constant<type1_, value1_>
05068 >::i1;
05069
05070
05071 template<
05072 typename type0_, type0_ value0_,
05073 typename type1_, type1_ value1_
05074 >
05075 class pack<
05076 constant<type0_, value0_>,
05077 constant<type1_, value1_>
05078 >
05079 {
05080 public:
05081 static const int n = 2;
05082
05083 typedef type0_ type0;
05084 typedef type1_ type1;
05085
05086 static const bool is_const0 = true;
05087 static const bool is_const1 = true;
05088 static const bool is_all_const = true;
05089 static const type0 i0 = value0_;
05090 static const type1 i1 = value1_;
05091
05092 LITE_INLINE pack()
05093 {}
05094
05095 LITE_INLINE pack(const type0& )
05096 {}
05097
05098 LITE_INLINE pack(
05099 const type0& ,
05100 const type1&
05101 ) {}
05102
05103 template<
05104 typename other_type0_ ,
05105 typename other_type1_
05106 >
05107 LITE_INLINE pack(const pack<
05108 other_type0_,
05109 other_type1_
05110 >& ) {}
05111
05112 LITE_INLINE pack&
05113 operator= (const pack& )
05114 {
05115 return *this;
05116 }
05117
05118 template<
05119 typename other_type0_ ,
05120 typename other_type1_
05121 >
05122 LITE_INLINE pack&
05123 operator=(const pack<
05124 other_type0_,
05125 other_type1_
05126 >& )
05127 {
05128 return *this;
05129 }
05130
05131 LITE_INLINE void set(
05132 const type0& ,
05133 const type1&
05134 )
05135 {
05136 }
05137 };
05138
05139
05140 template<
05141 typename type0_, type0_ value0_,
05142 typename type1_, type1_ value1_
05143 >
05144 const type0_ pack<
05145 constant<type0_, value0_>,
05146 constant<type1_, value1_>
05147 >::i0;
05148
05149 template<
05150 typename type0_, type0_ value0_,
05151 typename type1_, type1_ value1_
05152 >
05153 const type1_ pack<
05154 constant<type0_, value0_>,
05155 constant<type1_, value1_>
05156 >::i1;
05157
05158
05159 template<
05160 typename type0_
05161 >
05162 class pack<
05163 type0_
05164 >
05165 {
05166 public:
05167 static const int n = 1;
05168
05169 typedef type0_ type0;
05170
05171 static const bool is_const0 = false;
05172 static const bool is_all_const = false;
05173 type0 i0;
05174
05175 LITE_INLINE pack()
05176 : i0() {}
05177
05178
05179 LITE_INLINE pack(
05180 const type0& a0
05181 ) : i0(a0) {}
05182
05183 template<
05184 typename other_type0_
05185 >
05186 LITE_INLINE pack(const pack<
05187 other_type0_
05188 >& other) : i0(other.i0) {}
05189
05190 LITE_INLINE pack&
05191 operator= (const pack& other)
05192 {
05193 i0 = other.i0;
05194 return *this;
05195 }
05196
05197 template<
05198 typename other_type0_
05199 >
05200 LITE_INLINE pack&
05201 operator=(const pack<
05202 other_type0_
05203 >& other)
05204 {
05205 i0 = other.i0;
05206 return *this;
05207 }
05208
05209 LITE_INLINE void set(
05210 const type0& a0
05211 )
05212 {
05213 i0 = a0;
05214 }
05215 };
05216
05217
05218
05219 template<
05220 typename type0_, type0_ value0_
05221 >
05222 class pack<
05223 constant<type0_, value0_>
05224 >
05225 {
05226 public:
05227 static const int n = 1;
05228
05229 typedef type0_ type0;
05230
05231 static const bool is_const0 = true;
05232 static const bool is_all_const = true;
05233 static const type0 i0 = value0_;
05234
05235 LITE_INLINE pack()
05236 {}
05237
05238
05239 LITE_INLINE pack(
05240 const type0&
05241 ) {}
05242
05243 template<
05244 typename other_type0_
05245 >
05246 LITE_INLINE pack(const pack<
05247 other_type0_
05248 >& ) {}
05249
05250 LITE_INLINE pack&
05251 operator= (const pack& )
05252 {
05253 return *this;
05254 }
05255
05256 template<
05257 typename other_type0_
05258 >
05259 LITE_INLINE pack&
05260 operator=(const pack<
05261 other_type0_
05262 >& )
05263 {
05264 return *this;
05265 }
05266
05267 LITE_INLINE void set(
05268 const type0&
05269 )
05270 {
05271 }
05272 };
05273
05274
05275 template<
05276 typename type0_, type0_ value0_
05277 >
05278 const type0_ pack<
05279 constant<type0_, value0_>
05280 >::i0;
05281
05282
05283
05284
05285
05286
05287 template<>
05288 class pack<>
05289 {
05290 public:
05291 static const int n = 0;
05292
05293 LITE_INLINE pack() {}
05294
05295 LITE_INLINE pack(const pack&) {}
05296
05297 LITE_INLINE pack& operator= (const pack&)
05298 { return *this; }
05299
05300 LITE_INLINE void set()
05301 {}
05302 };
05303
05304 #endif // !DOCUMENTATION_ONLY
05305
05306
05307
05308
05309
05310 #ifdef DOCUMENTATION_ONLY
05311
05351 template<typename pack_type_, bool keep0_ ..., bool keepN_>
05352 class sub_pack
05353 {
05354 public:
05355 typedef pack_type_ input_pack_type;
05356
05357 typedef pack<...> type;
05358
05360 static void set(type& res, input_pack_type::type0 a0, ..., input_pack_type::typeN aN);
05361
05363 static void set(type& res, const input_pack_type& org);
05364 };
05365
05366 #else // DOCUMENTATION_ONLY
05367
05368
05369 template<
05370 >
05371 class sub_pack<
05372 pack<
05373 >
05374 >
05375 {
05376 public:
05377 typedef pack<
05378 > input_pack_type;
05379
05380 typedef pack<
05381 > type;
05382
05383 static LITE_INLINE void set(
05384 type& res
05385 )
05386 {
05387 res.set();
05388 }
05389
05390 static LITE_INLINE void set(type& res, const input_pack_type& org)
05391 {
05392 res.set();
05393 LITE_ARRAY_USE(org);
05394 }
05395 };
05396
05397
05398
05399 template<
05400 typename type0_
05401 >
05402 class sub_pack<
05403 pack<
05404 type0_
05405 >,
05406 false
05407 >
05408 {
05409 public:
05410 typedef pack<
05411 type0_
05412 > input_pack_type;
05413
05414 typedef pack<
05415 > type;
05416
05417 static LITE_INLINE void set(
05418 type& res,
05419 const typename input_pack_type::type0&
05420 )
05421 {
05422 res.set();
05423 }
05424
05425 static LITE_INLINE void set(type& res, const input_pack_type& org)
05426 {
05427 res.set();
05428 LITE_ARRAY_USE(org);
05429 }
05430 };
05431
05432
05433
05434 template<
05435 typename type0_
05436 >
05437 class sub_pack<
05438 pack<
05439 type0_
05440 >,
05441 true
05442 >
05443 {
05444 public:
05445 typedef pack<
05446 type0_
05447 > input_pack_type;
05448
05449 typedef pack<
05450 type0_
05451 > type;
05452
05453 static LITE_INLINE void set(
05454 type& res,
05455 const typename input_pack_type::type0& a0
05456 )
05457 {
05458 res.set(a0);
05459 }
05460
05461 static LITE_INLINE void set(type& res, const input_pack_type& org)
05462 {
05463 res.set(org.i0);
05464 LITE_ARRAY_USE(org);
05465 }
05466 };
05467
05468
05469
05470 template<
05471 typename type0_,
05472 typename type1_
05473 >
05474 class sub_pack<
05475 pack<
05476 type0_,
05477 type1_
05478 >,
05479 false,
05480 false
05481 >
05482 {
05483 public:
05484 typedef pack<
05485 type0_,
05486 type1_
05487 > input_pack_type;
05488
05489 typedef pack<
05490 > type;
05491
05492 static LITE_INLINE void set(
05493 type& res,
05494 const typename input_pack_type::type0& ,
05495 const typename input_pack_type::type1&
05496 )
05497 {
05498 res.set();
05499 }
05500
05501 static LITE_INLINE void set(type& res, const input_pack_type& org)
05502 {
05503 res.set();
05504 LITE_ARRAY_USE(org);
05505 }
05506 };
05507
05508
05509
05510 template<
05511 typename type0_,
05512 typename type1_
05513 >
05514 class sub_pack<
05515 pack<
05516 type0_,
05517 type1_
05518 >,
05519 true,
05520 false
05521 >
05522 {
05523 public:
05524 typedef pack<
05525 type0_,
05526 type1_
05527 > input_pack_type;
05528
05529 typedef pack<
05530 type0_
05531 > type;
05532
05533 static LITE_INLINE void set(
05534 type& res,
05535 const typename input_pack_type::type0& a0,
05536 const typename input_pack_type::type1&
05537 )
05538 {
05539 res.set(a0);
05540 }
05541
05542 static LITE_INLINE void set(type& res, const input_pack_type& org)
05543 {
05544 res.set(org.i0);
05545 LITE_ARRAY_USE(org);
05546 }
05547 };
05548
05549
05550
05551 template<
05552 typename type0_,
05553 typename type1_
05554 >
05555 class sub_pack<
05556 pack<
05557 type0_,
05558 type1_
05559 >,
05560 false,
05561 true
05562 >
05563 {
05564 public:
05565 typedef pack<
05566 type0_,
05567 type1_
05568 > input_pack_type;
05569
05570 typedef pack<
05571 type1_
05572 > type;
05573
05574 static LITE_INLINE void set(
05575 type& res,
05576 const typename input_pack_type::type0& ,
05577 const typename input_pack_type::type1& a1
05578 )
05579 {
05580 res.set(a1);
05581 }
05582
05583 static LITE_INLINE void set(type& res, const input_pack_type& org)
05584 {
05585 res.set(org.i1);
05586 LITE_ARRAY_USE(org);
05587 }
05588 };
05589
05590
05591
05592 template<
05593 typename type0_,
05594 typename type1_
05595 >
05596 class sub_pack<
05597 pack<
05598 type0_,
05599 type1_
05600 >,
05601 true,
05602 true
05603 >
05604 {
05605 public:
05606 typedef pack<
05607 type0_,
05608 type1_
05609 > input_pack_type;
05610
05611 typedef pack<
05612 type0_,
05613 type1_
05614 > type;
05615
05616 static LITE_INLINE void set(
05617 type& res,
05618 const typename input_pack_type::type0& a0,
05619 const typename input_pack_type::type1& a1
05620 )
05621 {
05622 res.set(a0,a1);
05623 }
05624
05625 static LITE_INLINE void set(type& res, const input_pack_type& org)
05626 {
05627 res.set(org.i0,org.i1);
05628 LITE_ARRAY_USE(org);
05629 }
05630 };
05631
05632
05633
05634 template<
05635 typename type0_,
05636 typename type1_,
05637 typename type2_
05638 >
05639 class sub_pack<
05640 pack<
05641 type0_,
05642 type1_,
05643 type2_
05644 >,
05645 false,
05646 false,
05647 false
05648 >
05649 {
05650 public:
05651 typedef pack<
05652 type0_,
05653 type1_,
05654 type2_
05655 > input_pack_type;
05656
05657 typedef pack<
05658 > type;
05659
05660 static LITE_INLINE void set(
05661 type& res,
05662 const typename input_pack_type::type0& ,
05663 const typename input_pack_type::type1& ,
05664 const typename input_pack_type::type2&
05665 )
05666 {
05667 res.set();
05668 }
05669
05670 static LITE_INLINE void set(type& res, const input_pack_type& org)
05671 {
05672 res.set();
05673 LITE_ARRAY_USE(org);
05674 }
05675 };
05676
05677
05678
05679 template<
05680 typename type0_,
05681 typename type1_,
05682 typename type2_
05683 >
05684 class sub_pack<
05685 pack<
05686 type0_,
05687 type1_,
05688 type2_
05689 >,
05690 true,
05691 false,
05692 false
05693 >
05694 {
05695 public:
05696 typedef pack<
05697 type0_,
05698 type1_,
05699 type2_
05700 > input_pack_type;
05701
05702 typedef pack<
05703 type0_
05704 > type;
05705
05706 static LITE_INLINE void set(
05707 type& res,
05708 const typename input_pack_type::type0& a0,
05709 const typename input_pack_type::type1& ,
05710 const typename input_pack_type::type2&
05711 )
05712 {
05713 res.set(a0);
05714 }
05715
05716 static LITE_INLINE void set(type& res, const input_pack_type& org)
05717 {
05718 res.set(org.i0);
05719 LITE_ARRAY_USE(org);
05720 }
05721 };
05722
05723
05724
05725 template<
05726 typename type0_,
05727 typename type1_,
05728 typename type2_
05729 >
05730 class sub_pack<
05731 pack<
05732 type0_,
05733 type1_,
05734 type2_
05735 >,
05736 false,
05737 true,
05738 false
05739 >
05740 {
05741 public:
05742 typedef pack<
05743 type0_,
05744 type1_,
05745 type2_
05746 > input_pack_type;
05747
05748 typedef pack<
05749 type1_
05750 > type;
05751
05752 static LITE_INLINE void set(
05753 type& res,
05754 const typename input_pack_type::type0& ,
05755 const typename input_pack_type::type1& a1,
05756 const typename input_pack_type::type2&
05757 )
05758 {
05759 res.set(a1);
05760 }
05761
05762 static LITE_INLINE void set(type& res, const input_pack_type& org)
05763 {
05764 res.set(org.i1);
05765 LITE_ARRAY_USE(org);
05766 }
05767 };
05768
05769
05770
05771 template<
05772 typename type0_,
05773 typename type1_,
05774 typename type2_
05775 >
05776 class sub_pack<
05777 pack<
05778 type0_,
05779 type1_,
05780 type2_
05781 >,
05782 true,
05783 true,
05784 false
05785 >
05786 {
05787 public:
05788 typedef pack<
05789 type0_,
05790 type1_,
05791 type2_
05792 > input_pack_type;
05793
05794 typedef pack<
05795 type0_,
05796 type1_
05797 > type;
05798
05799 static LITE_INLINE void set(
05800 type& res,
05801 const typename input_pack_type::type0& a0,
05802 const typename input_pack_type::type1& a1,
05803 const typename input_pack_type::type2&
05804 )
05805 {
05806 res.set(a0,a1);
05807 }
05808
05809 static LITE_INLINE void set(type& res, const input_pack_type& org)
05810 {
05811 res.set(org.i0,org.i1);
05812 LITE_ARRAY_USE(org);
05813 }
05814 };
05815
05816
05817
05818 template<
05819 typename type0_,
05820 typename type1_,
05821 typename type2_
05822 >
05823 class sub_pack<
05824 pack<
05825 type0_,
05826 type1_,
05827 type2_
05828 >,
05829 false,
05830 false,
05831 true
05832 >
05833 {
05834 public:
05835 typedef pack<
05836 type0_,
05837 type1_,
05838 type2_
05839 > input_pack_type;
05840
05841 typedef pack<
05842 type2_
05843 > type;
05844
05845 static LITE_INLINE void set(
05846 type& res,
05847 const typename input_pack_type::type0& ,
05848 const typename input_pack_type::type1& ,
05849 const typename input_pack_type::type2& a2
05850 )
05851 {
05852 res.set(a2);
05853 }
05854
05855 static LITE_INLINE void set(type& res, const input_pack_type& org)
05856 {
05857 res.set(org.i2);
05858 LITE_ARRAY_USE(org);
05859 }
05860 };
05861
05862
05863
05864 template<
05865 typename type0_,
05866 typename type1_,
05867 typename type2_
05868 >
05869 class sub_pack<
05870 pack<
05871 type0_,
05872 type1_,
05873 type2_
05874 >,
05875 true,
05876 false,
05877 true
05878 >
05879 {
05880 public:
05881 typedef pack<
05882 type0_,
05883 type1_,
05884 type2_
05885 > input_pack_type;
05886
05887 typedef pack<
05888 type0_,
05889 type2_
05890 > type;
05891
05892 static LITE_INLINE void set(
05893 type& res,
05894 const typename input_pack_type::type0& a0,
05895 const typename input_pack_type::type1& ,
05896 const typename input_pack_type::type2& a2
05897 )
05898 {
05899 res.set(a0,a2);
05900 }
05901
05902 static LITE_INLINE void set(type& res, const input_pack_type& org)
05903 {
05904 res.set(org.i0,org.i2);
05905 LITE_ARRAY_USE(org);
05906 }
05907 };
05908
05909
05910
05911 template<
05912 typename type0_,
05913 typename type1_,
05914 typename type2_
05915 >
05916 class sub_pack<
05917 pack<
05918 type0_,
05919 type1_,
05920 type2_
05921 >,
05922 false,
05923 true,
05924 true
05925 >
05926 {
05927 public:
05928 typedef pack<
05929 type0_,
05930 type1_,
05931 type2_
05932 > input_pack_type;
05933
05934 typedef pack<
05935 type1_,
05936 type2_
05937 > type;
05938
05939 static LITE_INLINE void set(
05940 type& res,
05941 const typename input_pack_type::type0& ,
05942 const typename input_pack_type::type1& a1,
05943 const typename input_pack_type::type2& a2
05944 )
05945 {
05946 res.set(a1,a2);
05947 }
05948
05949 static LITE_INLINE void set(type& res, const input_pack_type& org)
05950 {
05951 res.set(org.i1,org.i2);
05952 LITE_ARRAY_USE(org);
05953 }
05954 };
05955
05956
05957
05958 template<
05959 typename type0_,
05960 typename type1_,
05961 typename type2_
05962 >
05963 class sub_pack<
05964 pack<
05965 type0_,
05966 type1_,
05967 type2_
05968 >,
05969 true,
05970 true,
05971 true
05972 >
05973 {
05974 public:
05975 typedef pack<
05976 type0_,
05977 type1_,
05978 type2_
05979 > input_pack_type;
05980
05981 typedef pack<
05982 type0_,
05983 type1_,
05984 type2_
05985 > type;
05986
05987 static LITE_INLINE void set(
05988 type& res,
05989 const typename input_pack_type::type0& a0,
05990 const typename input_pack_type::type1& a1,
05991 const typename input_pack_type::type2& a2
05992 )
05993 {
05994 res.set(a0,a1,a2);
05995 }
05996
05997 static LITE_INLINE void set(type& res, const input_pack_type& org)
05998 {
05999 res.set(org.i0,org.i1,org.i2);
06000 LITE_ARRAY_USE(org);
06001 }
06002 };
06003
06004
06005
06006 template<
06007 typename type0_,
06008 typename type1_,
06009 typename type2_,
06010 typename type3_
06011 >
06012 class sub_pack<
06013 pack<
06014 type0_,
06015 type1_,
06016 type2_,
06017 type3_
06018 >,
06019 false,
06020 false,
06021 false,
06022 false
06023 >
06024 {
06025 public:
06026 typedef pack<
06027 type0_,
06028 type1_,
06029 type2_,
06030 type3_
06031 > input_pack_type;
06032
06033 typedef pack<
06034 > type;
06035
06036 static LITE_INLINE void set(
06037 type& res,
06038 const typename input_pack_type::type0& ,
06039 const typename input_pack_type::type1& ,
06040 const typename input_pack_type::type2& ,
06041 const typename input_pack_type::type3&
06042 )
06043 {
06044 res.set();
06045 }
06046
06047 static LITE_INLINE void set(type& res, const input_pack_type& org)
06048 {
06049 res.set();
06050 LITE_ARRAY_USE(org);
06051 }
06052 };
06053
06054
06055
06056 template<
06057 typename type0_,
06058 typename type1_,
06059 typename type2_,
06060 typename type3_
06061 >
06062 class sub_pack<
06063 pack<
06064 type0_,
06065 type1_,
06066 type2_,
06067 type3_
06068 >,
06069 true,
06070 false,
06071 false,
06072 false
06073 >
06074 {
06075 public:
06076 typedef pack<
06077 type0_,
06078 type1_,
06079 type2_,
06080 type3_
06081 > input_pack_type;
06082
06083 typedef pack<
06084 type0_
06085 > type;
06086
06087 static LITE_INLINE void set(
06088 type& res,
06089 const typename input_pack_type::type0& a0,
06090 const typename input_pack_type::type1& ,
06091 const typename input_pack_type::type2& ,
06092 const typename input_pack_type::type3&
06093 )
06094 {
06095 res.set(a0);
06096 }
06097
06098 static LITE_INLINE void set(type& res, const input_pack_type& org)
06099 {
06100 res.set(org.i0);
06101 LITE_ARRAY_USE(org);
06102 }
06103 };
06104
06105
06106
06107 template<
06108 typename type0_,
06109 typename type1_,
06110 typename type2_,
06111 typename type3_
06112 >
06113 class sub_pack<
06114 pack<
06115 type0_,
06116 type1_,
06117 type2_,
06118 type3_
06119 >,
06120 false,
06121 true,
06122 false,
06123 false
06124 >
06125 {
06126 public:
06127 typedef pack<
06128 type0_,
06129 type1_,
06130 type2_,
06131 type3_
06132 > input_pack_type;
06133
06134 typedef pack<
06135 type1_
06136 > type;
06137
06138 static LITE_INLINE void set(
06139 type& res,
06140 const typename input_pack_type::type0& ,
06141 const typename input_pack_type::type1& a1,
06142 const typename input_pack_type::type2& ,
06143 const typename input_pack_type::type3&
06144 )
06145 {
06146 res.set(a1);
06147 }
06148
06149 static LITE_INLINE void set(type& res, const input_pack_type& org)
06150 {
06151 res.set(org.i1);
06152 LITE_ARRAY_USE(org);
06153 }
06154 };
06155
06156
06157
06158 template<
06159 typename type0_,
06160 typename type1_,
06161 typename type2_,
06162 typename type3_
06163 >
06164 class sub_pack<
06165 pack<
06166 type0_,
06167 type1_,
06168 type2_,
06169 type3_
06170 >,
06171 true,
06172 true,
06173 false,
06174 false
06175 >
06176 {
06177 public:
06178 typedef pack<
06179 type0_,
06180 type1_,
06181 type2_,
06182 type3_
06183 > input_pack_type;
06184
06185 typedef pack<
06186 type0_,
06187 type1_
06188 > type;
06189
06190 static LITE_INLINE void set(
06191 type& res,
06192 const typename input_pack_type::type0& a0,
06193 const typename input_pack_type::type1& a1,
06194 const typename input_pack_type::type2& ,
06195 const typename input_pack_type::type3&
06196 )
06197 {
06198 res.set(a0,a1);
06199 }
06200
06201 static LITE_INLINE void set(type& res, const input_pack_type& org)
06202 {
06203 res.set(org.i0,org.i1);
06204 LITE_ARRAY_USE(org);
06205 }
06206 };
06207
06208
06209
06210 template<
06211 typename type0_,
06212 typename type1_,
06213 typename type2_,
06214 typename type3_
06215 >
06216 class sub_pack<
06217 pack<
06218 type0_,
06219 type1_,
06220 type2_,
06221 type3_
06222 >,
06223 false,
06224 false,
06225 true,
06226 false
06227 >
06228 {
06229 public:
06230 typedef pack<
06231 type0_,
06232 type1_,
06233 type2_,
06234 type3_
06235 > input_pack_type;
06236
06237 typedef pack<
06238 type2_
06239 > type;
06240
06241 static LITE_INLINE void set(
06242 type& res,
06243 const typename input_pack_type::type0& ,
06244 const typename input_pack_type::type1& ,
06245 const typename input_pack_type::type2& a2,
06246 const typename input_pack_type::type3&
06247 )
06248 {
06249 res.set(a2);
06250 }
06251
06252 static LITE_INLINE void set(type& res, const input_pack_type& org)
06253 {
06254 res.set(org.i2);
06255 LITE_ARRAY_USE(org);
06256 }
06257 };
06258
06259
06260
06261 template<
06262 typename type0_,
06263 typename type1_,
06264 typename type2_,
06265 typename type3_
06266 >
06267 class sub_pack<
06268 pack<
06269 type0_,
06270 type1_,
06271 type2_,
06272 type3_
06273 >,
06274 true,
06275 false,
06276 true,
06277 false
06278 >
06279 {
06280 public:
06281 typedef pack<
06282 type0_,
06283 type1_,
06284 type2_,
06285 type3_
06286 > input_pack_type;
06287
06288 typedef pack<
06289 type0_,
06290 type2_
06291 > type;
06292
06293 static LITE_INLINE void set(
06294 type& res,
06295 const typename input_pack_type::type0& a0,
06296 const typename input_pack_type::type1& ,
06297 const typename input_pack_type::type2& a2,
06298 const typename input_pack_type::type3&
06299 )
06300 {
06301 res.set(a0,a2);
06302 }
06303
06304 static LITE_INLINE void set(type& res, const input_pack_type& org)
06305 {
06306 res.set(org.i0,org.i2);
06307 LITE_ARRAY_USE(org);
06308 }
06309 };
06310
06311
06312
06313 template<
06314 typename type0_,
06315 typename type1_,
06316 typename type2_,
06317 typename type3_
06318 >
06319 class sub_pack<
06320 pack<
06321 type0_,
06322 type1_,
06323 type2_,
06324 type3_
06325 >,
06326 false,
06327 true,
06328 true,
06329 false
06330 >
06331 {
06332 public:
06333 typedef pack<
06334 type0_,
06335 type1_,
06336 type2_,
06337 type3_
06338 > input_pack_type;
06339
06340 typedef pack<
06341 type1_,
06342 type2_
06343 > type;
06344
06345 static LITE_INLINE void set(
06346 type& res,
06347 const typename input_pack_type::type0& ,
06348 const typename input_pack_type::type1& a1,
06349 const typename input_pack_type::type2& a2,
06350 const typename input_pack_type::type3&
06351 )
06352 {
06353 res.set(a1,a2);
06354 }
06355
06356 static LITE_INLINE void set(type& res, const input_pack_type& org)
06357 {
06358 res.set(org.i1,org.i2);
06359 LITE_ARRAY_USE(org);
06360 }
06361 };
06362
06363
06364
06365 template<
06366 typename type0_,
06367 typename type1_,
06368 typename type2_,
06369 typename type3_
06370 >
06371 class sub_pack<
06372 pack<
06373 type0_,
06374 type1_,
06375 type2_,
06376 type3_
06377 >,
06378 true,
06379 true,
06380 true,
06381 false
06382 >
06383 {
06384 public:
06385 typedef pack<
06386 type0_,
06387 type1_,
06388 type2_,
06389 type3_
06390 > input_pack_type;
06391
06392 typedef pack<
06393 type0_,
06394 type1_,
06395 type2_
06396 > type;
06397
06398 static LITE_INLINE void set(
06399 type& res,
06400 const typename input_pack_type::type0& a0,
06401 const typename input_pack_type::type1& a1,
06402 const typename input_pack_type::type2& a2,
06403 const typename input_pack_type::type3&
06404 )
06405 {
06406 res.set(a0,a1,a2);
06407 }
06408
06409 static LITE_INLINE void set(type& res, const input_pack_type& org)
06410 {
06411 res.set(org.i0,org.i1,org.i2);
06412 LITE_ARRAY_USE(org);
06413 }
06414 };
06415
06416
06417
06418 template<
06419 typename type0_,
06420 typename type1_,
06421 typename type2_,
06422 typename type3_
06423 >
06424 class sub_pack<
06425 pack<
06426 type0_,
06427 type1_,
06428 type2_,
06429 type3_
06430 >,
06431 false,
06432 false,
06433 false,
06434 true
06435 >
06436 {
06437 public:
06438 typedef pack<
06439 type0_,
06440 type1_,
06441 type2_,
06442 type3_
06443 > input_pack_type;
06444
06445 typedef pack<
06446 type3_
06447 > type;
06448
06449 static LITE_INLINE void set(
06450 type& res,
06451 const typename input_pack_type::type0& ,
06452 const typename input_pack_type::type1& ,
06453 const typename input_pack_type::type2& ,
06454 const typename input_pack_type::type3& a3
06455 )
06456 {
06457 res.set(a3);
06458 }
06459
06460 static LITE_INLINE void set(type& res, const input_pack_type& org)
06461 {
06462 res.set(org.i3);
06463 LITE_ARRAY_USE(org);
06464 }
06465 };
06466
06467
06468
06469 template<
06470 typename type0_,
06471 typename type1_,
06472 typename type2_,
06473 typename type3_
06474 >
06475 class sub_pack<
06476 pack<
06477 type0_,
06478 type1_,
06479 type2_,
06480 type3_
06481 >,
06482 true,
06483 false,
06484 false,
06485 true
06486 >
06487 {
06488 public:
06489 typedef pack<
06490 type0_,
06491 type1_,
06492 type2_,
06493 type3_
06494 > input_pack_type;
06495
06496 typedef pack<
06497 type0_,
06498 type3_
06499 > type;
06500
06501 static LITE_INLINE void set(
06502 type& res,
06503 const typename input_pack_type::type0& a0,
06504 const typename input_pack_type::type1& ,
06505 const typename input_pack_type::type2& ,
06506 const typename input_pack_type::type3& a3
06507 )
06508 {
06509 res.set(a0,a3);
06510 }
06511
06512 static LITE_INLINE void set(type& res, const input_pack_type& org)
06513 {
06514 res.set(org.i0,org.i3);
06515 LITE_ARRAY_USE(org);
06516 }
06517 };
06518
06519
06520
06521 template<
06522 typename type0_,
06523 typename type1_,
06524 typename type2_,
06525 typename type3_
06526 >
06527 class sub_pack<
06528 pack<
06529 type0_,
06530 type1_,
06531 type2_,
06532 type3_
06533 >,
06534 false,
06535 true,
06536 false,
06537 true
06538 >
06539 {
06540 public:
06541 typedef pack<
06542 type0_,
06543 type1_,
06544 type2_,
06545 type3_
06546 > input_pack_type;
06547
06548 typedef pack<
06549 type1_,
06550 type3_
06551 > type;
06552
06553 static LITE_INLINE void set(
06554 type& res,
06555 const typename input_pack_type::type0& ,
06556 const typename input_pack_type::type1& a1,
06557 const typename input_pack_type::type2& ,
06558 const typename input_pack_type::type3& a3
06559 )
06560 {
06561 res.set(a1,a3);
06562 }
06563
06564 static LITE_INLINE void set(type& res, const input_pack_type& org)
06565 {
06566 res.set(org.i1,org.i3);
06567 LITE_ARRAY_USE(org);
06568 }
06569 };
06570
06571
06572
06573 template<
06574 typename type0_,
06575 typename type1_,
06576 typename type2_,
06577 typename type3_
06578 >
06579 class sub_pack<
06580 pack<
06581 type0_,
06582 type1_,
06583 type2_,
06584 type3_
06585 >,
06586 true,
06587 true,
06588 false,
06589 true
06590 >
06591 {
06592 public:
06593 typedef pack<
06594 type0_,
06595 type1_,
06596 type2_,
06597 type3_
06598 > input_pack_type;
06599
06600 typedef pack<
06601 type0_,
06602 type1_,
06603 type3_
06604 > type;
06605
06606 static LITE_INLINE void set(
06607 type& res,
06608 const typename input_pack_type::type0& a0,
06609 const typename input_pack_type::type1& a1,
06610 const typename input_pack_type::type2& ,
06611 const typename input_pack_type::type3& a3
06612 )
06613 {
06614 res.set(a0,a1,a3);
06615 }
06616
06617 static LITE_INLINE void set(type& res, const input_pack_type& org)
06618 {
06619 res.set(org.i0,org.i1,org.i3);
06620 LITE_ARRAY_USE(org);
06621 }
06622 };
06623
06624
06625
06626 template<
06627 typename type0_,
06628 typename type1_,
06629 typename type2_,
06630 typename type3_
06631 >
06632 class sub_pack<
06633 pack<
06634 type0_,
06635 type1_,
06636 type2_,
06637 type3_
06638 >,
06639 false,
06640 false,
06641 true,
06642 true
06643 >
06644 {
06645 public:
06646 typedef pack<
06647 type0_,
06648 type1_,
06649 type2_,
06650 type3_
06651 > input_pack_type;
06652
06653 typedef pack<
06654 type2_,
06655 type3_
06656 > type;
06657
06658 static LITE_INLINE void set(
06659 type& res,
06660 const typename input_pack_type::type0& ,
06661 const typename input_pack_type::type1& ,
06662 const typename input_pack_type::type2& a2,
06663 const typename input_pack_type::type3& a3
06664 )
06665 {
06666 res.set(a2,a3);
06667 }
06668
06669 static LITE_INLINE void set(type& res, const input_pack_type& org)
06670 {
06671 res.set(org.i2,org.i3);
06672 LITE_ARRAY_USE(org);
06673 }
06674 };
06675
06676
06677
06678 template<
06679 typename type0_,
06680 typename type1_,
06681 typename type2_,
06682 typename type3_
06683 >
06684 class sub_pack<
06685 pack<
06686 type0_,
06687 type1_,
06688 type2_,
06689 type3_
06690 >,
06691 true,
06692 false,
06693 true,
06694 true
06695 >
06696 {
06697 public:
06698 typedef pack<
06699 type0_,
06700 type1_,
06701 type2_,
06702 type3_
06703 > input_pack_type;
06704
06705 typedef pack<
06706 type0_,
06707 type2_,
06708 type3_
06709 > type;
06710
06711 static LITE_INLINE void set(
06712 type& res,
06713 const typename input_pack_type::type0& a0,
06714 const typename input_pack_type::type1& ,
06715 const typename input_pack_type::type2& a2,
06716 const typename input_pack_type::type3& a3
06717 )
06718 {
06719 res.set(a0,a2,a3);
06720 }
06721
06722 static LITE_INLINE void set(type& res, const input_pack_type& org)
06723 {
06724 res.set(org.i0,org.i2,org.i3);
06725 LITE_ARRAY_USE(org);
06726 }
06727 };
06728
06729
06730
06731 template<
06732 typename type0_,
06733 typename type1_,
06734 typename type2_,
06735 typename type3_
06736 >
06737 class sub_pack<
06738 pack<
06739 type0_,
06740 type1_,
06741 type2_,
06742 type3_
06743 >,
06744 false,
06745 true,
06746 true,
06747 true
06748 >
06749 {
06750 public:
06751 typedef pack<
06752 type0_,
06753 type1_,
06754 type2_,
06755 type3_
06756 > input_pack_type;
06757
06758 typedef pack<
06759 type1_,
06760 type2_,
06761 type3_
06762 > type;
06763
06764 static LITE_INLINE void set(
06765 type& res,
06766 const typename input_pack_type::type0& ,
06767 const typename input_pack_type::type1& a1,
06768 const typename input_pack_type::type2& a2,
06769 const typename input_pack_type::type3& a3
06770 )
06771 {
06772 res.set(a1,a2,a3);
06773 }
06774
06775 static LITE_INLINE void set(type& res, const input_pack_type& org)
06776 {
06777 res.set(org.i1,org.i2,org.i3);
06778 LITE_ARRAY_USE(org);
06779 }
06780 };
06781
06782
06783
06784 template<
06785 typename type0_,
06786 typename type1_,
06787 typename type2_,
06788 typename type3_
06789 >
06790 class sub_pack<
06791 pack<
06792 type0_,
06793 type1_,
06794 type2_,
06795 type3_
06796 >,
06797 true,
06798 true,
06799 true,
06800 true
06801 >
06802 {
06803 public:
06804 typedef pack<
06805 type0_,
06806 type1_,
06807 type2_,
06808 type3_
06809 > input_pack_type;
06810
06811 typedef pack<
06812 type0_,
06813 type1_,
06814 type2_,
06815 type3_
06816 > type;
06817
06818 static LITE_INLINE void set(
06819 type& res,
06820 const typename input_pack_type::type0& a0,
06821 const typename input_pack_type::type1& a1,
06822 const typename input_pack_type::type2& a2,
06823 const typename input_pack_type::type3& a3
06824 )
06825 {
06826 res.set(a0,a1,a2,a3);
06827 }
06828
06829 static LITE_INLINE void set(type& res, const input_pack_type& org)
06830 {
06831 res.set(org.i0,org.i1,org.i2,org.i3);
06832 LITE_ARRAY_USE(org);
06833 }
06834 };
06835
06836
06837
06838 #endif // !DOCUMENTATION_ONLY
06839
06840
06841
06842
06843
06844 #ifdef DOCUMENTATION_ONLY
06845
06866 template<int index_, typename type_>
06867 struct get_type
06868 {
06869 typedef ... type;
06870 };
06871
06872 #else // DOCUMENTATION_ONLY
06873
06874
06875 template<int index_, typename type_>
06876 struct get_type;
06877
06878 template<typename type_>
06879 struct get_type<0, type_>
06880 {
06881 typedef typename type_::type0 type;
06882 };
06883 template<typename type_>
06884 struct get_type<1, type_>
06885 {
06886 typedef typename type_::type1 type;
06887 };
06888 template<typename type_>
06889 struct get_type<2, type_>
06890 {
06891 typedef typename type_::type2 type;
06892 };
06893 template<typename type_>
06894 struct get_type<3, type_>
06895 {
06896 typedef typename type_::type3 type;
06897 };
06898
06899 #endif // !DOCUMENTATION_ONLY
06900
06901
06902
06903
06904
06905 #ifdef DOCUMENTATION_ONLY
06906
06924 template<int index_, typename type_>
06925 typename get_type<index_, type_>::type get(const type_& a);
06926
06927 #else // DOCUMENTATION_ONLY
06928
06929 template<int index_, typename type_>
06930 LITE_INLINE
06931 typename detail::enable_if<index_==0, typename get_type<index_, type_>::type>::type
06932 get(const type_& a)
06933 {
06934 LITE_ARRAY_USE(a);
06935 return a.i0;
06936 };
06937
06938 template<int index_, typename type_>
06939 LITE_INLINE
06940 typename detail::enable_if<index_==1, typename get_type<index_, type_>::type>::type
06941 get(const type_& a)
06942 {
06943 LITE_ARRAY_USE(a);
06944 return a.i1;
06945 };
06946
06947 template<int index_, typename type_>
06948 LITE_INLINE
06949 typename detail::enable_if<index_==2, typename get_type<index_, type_>::type>::type
06950 get(const type_& a)
06951 {
06952 LITE_ARRAY_USE(a);
06953 return a.i2;
06954 };
06955
06956 template<int index_, typename type_>
06957 LITE_INLINE
06958 typename detail::enable_if<index_==3, typename get_type<index_, type_>::type>::type
06959 get(const type_& a)
06960 {
06961 LITE_ARRAY_USE(a);
06962 return a.i3;
06963 };
06964
06965
06966 #endif // DOCUMENTATION_ONLY
06967
06968
06969
06970
06971 #ifdef DOCUMENTATION_ONLY
06972
06993 template<int index_, typename type_, typename value_type_>
06994 void set(type_& a, const value_type_& v);
06995
06996 #else // DOCUMENTATION_ONLY
06997
06998
06999 template<int index_, typename type_, typename value_type_>
07000 LITE_INLINE
07001 typename detail::enable_if<index_==0 && type_::is_const0>::type
07002 set(type_&, const value_type_&)
07003 {}
07004
07005 template<int index_, typename type_, typename value_type_>
07006 LITE_INLINE
07007 typename detail::enable_if<index_==0 && !type_::is_const0>::type
07008 set(type_& a, const value_type_& v)
07009 {
07010 a.i0 = v;
07011 }
07012
07013 template<int index_, typename type_, typename value_type_>
07014 LITE_INLINE
07015 typename detail::enable_if<index_==1 && type_::is_const1>::type
07016 set(type_&, const value_type_&)
07017 {}
07018
07019 template<int index_, typename type_, typename value_type_>
07020 LITE_INLINE
07021 typename detail::enable_if<index_==1 && !type_::is_const1>::type
07022 set(type_& a, const value_type_& v)
07023 {
07024 a.i1 = v;
07025 }
07026
07027 template<int index_, typename type_, typename value_type_>
07028 LITE_INLINE
07029 typename detail::enable_if<index_==2 && type_::is_const2>::type
07030 set(type_&, const value_type_&)
07031 {}
07032
07033 template<int index_, typename type_, typename value_type_>
07034 LITE_INLINE
07035 typename detail::enable_if<index_==2 && !type_::is_const2>::type
07036 set(type_& a, const value_type_& v)
07037 {
07038 a.i2 = v;
07039 }
07040
07041 template<int index_, typename type_, typename value_type_>
07042 LITE_INLINE
07043 typename detail::enable_if<index_==3 && type_::is_const3>::type
07044 set(type_&, const value_type_&)
07045 {}
07046
07047 template<int index_, typename type_, typename value_type_>
07048 LITE_INLINE
07049 typename detail::enable_if<index_==3 && !type_::is_const3>::type
07050 set(type_& a, const value_type_& v)
07051 {
07052 a.i3 = v;
07053 }
07054
07055 #endif // DOCUMENTATION_ONLY
07056
07057
07058
07059 #ifdef DOCUMENTATION_ONLY
07060
07065 template<typename l_type0_, ..., typename l_typeN_, typename r_type0_, ..., typename r_typeN_>
07066 bool operator<(const pack<l_type0_, ..., l_typeN_>&a, const pack<r_type0_, ..., r_typeN_>& b);
07067 #endif // DOCUMENTATION_ONLY
07068
07069 LITE_INLINE
07070 bool operator<(const pack<>&, const pack<>&)
07071 {
07072 return false;
07073 }
07074
07075 template<
07076 typename l_type0_,
07077 typename r_type0_
07078 >
07079 LITE_INLINE
07080 bool operator<(
07081 const pack<l_type0_>& a,
07082 const pack<r_type0_>& b)
07083 {
07084 return a.i0<b.i0;
07085 LITE_ARRAY_USE(a);
07086 LITE_ARRAY_USE(b);
07087 }
07088
07089 template<
07090 typename l_type0_,
07091 typename l_type1_,
07092 typename r_type0_,
07093 typename r_type1_
07094 >
07095 LITE_INLINE
07096 bool operator<(
07097 const pack<l_type0_, l_type1_>& a,
07098 const pack<r_type0_, r_type1_>& b)
07099 {
07100 return a.i0<b.i0 && a.i1<b.i1;
07101 LITE_ARRAY_USE(a);
07102 LITE_ARRAY_USE(b);
07103 }
07104
07105 template<
07106 typename l_type0_,
07107 typename l_type1_,
07108 typename l_type2_,
07109 typename r_type0_,
07110 typename r_type1_,
07111 typename r_type2_
07112 >
07113 LITE_INLINE
07114 bool operator<(
07115 const pack<l_type0_, l_type1_, l_type2_>& a,
07116 const pack<r_type0_, r_type1_, r_type2_>& b)
07117 {
07118 return a.i0<b.i0 && a.i1<b.i1 && a.i2<b.i2;
07119 LITE_ARRAY_USE(a);
07120 LITE_ARRAY_USE(b);
07121 }
07122
07123
07124
07125
07126 #ifdef DOCUMENTATION_ONLY
07127
07132 template<typename l_type0_, ..., typename l_typeN_, typename r_type0_, ..., typename r_typeN_>
07133 bool operator<=(const pack<l_type0_, ..., l_typeN_>&a, const pack<r_type0_, ..., r_typeN_>& b);
07134 #endif // DOCUMENTATION_ONLY
07135
07136 LITE_INLINE
07137 bool operator<=(const pack<>&, const pack<>&)
07138 {
07139 return true;
07140 }
07141
07142 template<
07143 typename l_type0_,
07144 typename r_type0_
07145 >
07146 LITE_INLINE
07147 bool operator<=(
07148 const pack<l_type0_>& a,
07149 const pack<r_type0_>& b)
07150 {
07151 return a.i0<=b.i0;
07152 LITE_ARRAY_USE(a);
07153 LITE_ARRAY_USE(b);
07154 }
07155
07156 template<
07157 typename l_type0_,
07158 typename l_type1_,
07159 typename r_type0_,
07160 typename r_type1_
07161 >
07162 LITE_INLINE
07163 bool operator<=(
07164 const pack<l_type0_, l_type1_>& a,
07165 const pack<r_type0_, r_type1_>& b)
07166 {
07167 return a.i0<=b.i0 && a.i1<=b.i1;
07168 LITE_ARRAY_USE(a);
07169 LITE_ARRAY_USE(b);
07170 }
07171
07172 template<
07173 typename l_type0_,
07174 typename l_type1_,
07175 typename l_type2_,
07176 typename r_type0_,
07177 typename r_type1_,
07178 typename r_type2_
07179 >
07180 LITE_INLINE
07181 bool operator<=(
07182 const pack<l_type0_, l_type1_, l_type2_>& a,
07183 const pack<r_type0_, r_type1_, r_type2_>& b)
07184 {
07185 return a.i0<=b.i0 && a.i1<=b.i1 && a.i2<=b.i2;
07186 LITE_ARRAY_USE(a);
07187 LITE_ARRAY_USE(b);
07188 }
07189
07190
07191
07192
07193 #ifdef DOCUMENTATION_ONLY
07194
07199 template<typename l_type0_, ..., typename l_typeN_, typename r_type0_, ..., typename r_typeN_>
07200 bool operator==(const pack<l_type0_, ..., l_typeN_>&a, const pack<r_type0_, ..., r_typeN_>& b);
07201 #endif // DOCUMENTATION_ONLY
07202
07203 LITE_INLINE
07204 bool operator==(const pack<>&, const pack<>&)
07205 {
07206 return true;
07207 }
07208
07209 template<
07210 typename l_type0_,
07211 typename r_type0_
07212 >
07213 LITE_INLINE
07214 bool operator==(
07215 const pack<l_type0_>& a,
07216 const pack<r_type0_>& b)
07217 {
07218 return a.i0==b.i0;
07219 LITE_ARRAY_USE(a);
07220 LITE_ARRAY_USE(b);
07221 }
07222
07223 template<
07224 typename l_type0_,
07225 typename l_type1_,
07226 typename r_type0_,
07227 typename r_type1_
07228 >
07229 LITE_INLINE
07230 bool operator==(
07231 const pack<l_type0_, l_type1_>& a,
07232 const pack<r_type0_, r_type1_>& b)
07233 {
07234 return a.i0==b.i0 && a.i1==b.i1;
07235 LITE_ARRAY_USE(a);
07236 LITE_ARRAY_USE(b);
07237 }
07238
07239 template<
07240 typename l_type0_,
07241 typename l_type1_,
07242 typename l_type2_,
07243 typename r_type0_,
07244 typename r_type1_,
07245 typename r_type2_
07246 >
07247 LITE_INLINE
07248 bool operator==(
07249 const pack<l_type0_, l_type1_, l_type2_>& a,
07250 const pack<r_type0_, r_type1_, r_type2_>& b)
07251 {
07252 return a.i0==b.i0 && a.i1==b.i1 && a.i2==b.i2;
07253 LITE_ARRAY_USE(a);
07254 LITE_ARRAY_USE(b);
07255 }
07256
07257
07258
07259
07260 #ifdef DOCUMENTATION_ONLY
07261
07266 template<typename l_type0_, ..., typename l_typeN_, typename r_type0_, ..., typename r_typeN_>
07267 bool operator>=(const pack<l_type0_, ..., l_typeN_>&a, const pack<r_type0_, ..., r_typeN_>& b);
07268 #endif // DOCUMENTATION_ONLY
07269
07270 LITE_INLINE
07271 bool operator>=(const pack<>&, const pack<>&)
07272 {
07273 return true;
07274 }
07275
07276 template<
07277 typename l_type0_,
07278 typename r_type0_
07279 >
07280 LITE_INLINE
07281 bool operator>=(
07282 const pack<l_type0_>& a,
07283 const pack<r_type0_>& b)
07284 {
07285 return a.i0>=b.i0;
07286 LITE_ARRAY_USE(a);
07287 LITE_ARRAY_USE(b);
07288 }
07289
07290 template<
07291 typename l_type0_,
07292 typename l_type1_,
07293 typename r_type0_,
07294 typename r_type1_
07295 >
07296 LITE_INLINE
07297 bool operator>=(
07298 const pack<l_type0_, l_type1_>& a,
07299 const pack<r_type0_, r_type1_>& b)
07300 {
07301 return a.i0>=b.i0 && a.i1>=b.i1;
07302 LITE_ARRAY_USE(a);
07303 LITE_ARRAY_USE(b);
07304 }
07305
07306 template<
07307 typename l_type0_,
07308 typename l_type1_,
07309 typename l_type2_,
07310 typename r_type0_,
07311 typename r_type1_,
07312 typename r_type2_
07313 >
07314 LITE_INLINE
07315 bool operator>=(
07316 const pack<l_type0_, l_type1_, l_type2_>& a,
07317 const pack<r_type0_, r_type1_, r_type2_>& b)
07318 {
07319 return a.i0>=b.i0 && a.i1>=b.i1 && a.i2>=b.i2;
07320 LITE_ARRAY_USE(a);
07321 LITE_ARRAY_USE(b);
07322 }
07323
07324
07325
07326
07327 #ifdef DOCUMENTATION_ONLY
07328
07333 template<typename l_type0_, ..., typename l_typeN_, typename r_type0_, ..., typename r_typeN_>
07334 bool operator>(const pack<l_type0_, ..., l_typeN_>&a, const pack<r_type0_, ..., r_typeN_>& b);
07335 #endif // DOCUMENTATION_ONLY
07336
07337 LITE_INLINE
07338 bool operator>(const pack<>&, const pack<>&)
07339 {
07340 return false;
07341 }
07342
07343 template<
07344 typename l_type0_,
07345 typename r_type0_
07346 >
07347 LITE_INLINE
07348 bool operator>(
07349 const pack<l_type0_>& a,
07350 const pack<r_type0_>& b)
07351 {
07352 return a.i0>b.i0;
07353 LITE_ARRAY_USE(a);
07354 LITE_ARRAY_USE(b);
07355 }
07356
07357 template<
07358 typename l_type0_,
07359 typename l_type1_,
07360 typename r_type0_,
07361 typename r_type1_
07362 >
07363 LITE_INLINE
07364 bool operator>(
07365 const pack<l_type0_, l_type1_>& a,
07366 const pack<r_type0_, r_type1_>& b)
07367 {
07368 return a.i0>b.i0 && a.i1>b.i1;
07369 LITE_ARRAY_USE(a);
07370 LITE_ARRAY_USE(b);
07371 }
07372
07373 template<
07374 typename l_type0_,
07375 typename l_type1_,
07376 typename l_type2_,
07377 typename r_type0_,
07378 typename r_type1_,
07379 typename r_type2_
07380 >
07381 LITE_INLINE
07382 bool operator>(
07383 const pack<l_type0_, l_type1_, l_type2_>& a,
07384 const pack<r_type0_, r_type1_, r_type2_>& b)
07385 {
07386 return a.i0>b.i0 && a.i1>b.i1 && a.i2>b.i2;
07387 LITE_ARRAY_USE(a);
07388 LITE_ARRAY_USE(b);
07389 }
07390
07391
07392
07393
07394
07395
07396 #ifdef DOCUMENTATION_ONLY
07397
07403 template<typename l_type0_, ..., typename l_typeN_, typename r_type0_, ..., typename r_typeN_>
07404 bool operator!=(const pack<l_type0_, ..., l_typeN_>&a, const pack<r_type0_, ..., r_typeN_>& b);
07405
07406 #else // DOCUMENTATION_ONLY
07407
07408 LITE_INLINE
07409 bool operator!=(const pack<>&, const pack<>&)
07410 {
07411 return false;
07412 }
07413
07414 template<
07415 typename l_type0_,
07416 typename r_type0_
07417 >
07418 LITE_INLINE
07419 bool operator!=(
07420 const pack<l_type0_>& a,
07421 const pack<r_type0_>& b)
07422 {
07423 return !(a==b);
07424 }
07425
07426 template<
07427 typename l_type0_,
07428 typename l_type1_,
07429 typename r_type0_,
07430 typename r_type1_
07431 >
07432 LITE_INLINE
07433 bool operator!=(
07434 const pack<l_type0_,l_type1_>& a,
07435 const pack<r_type0_,r_type1_>& b)
07436 {
07437 return !(a==b);
07438 }
07439
07440 template<
07441 typename l_type0_,
07442 typename l_type1_,
07443 typename l_type2_,
07444 typename r_type0_,
07445 typename r_type1_,
07446 typename r_type2_
07447 >
07448 LITE_INLINE
07449 bool operator!=(
07450 const pack<l_type0_,l_type1_,l_type2_>& a,
07451 const pack<r_type0_,r_type1_,r_type2_>& b)
07452 {
07453 return !(a==b);
07454 }
07455
07456
07457 #endif // !DOCUMENTATION_ONLY
07458
07459
07460
07461
07462 #ifdef DOCUMENTATION_ONLY
07463
07486 template<typename char_type_, typename traits_type_, typename type0_, ..., typename typeN_>
07487 std::basic_ostream<char_type_, traits_type_>&
07488 operator<<(
07489 std::basic_ostream<char_type_, traits_type_>& os,
07490 const pack<type0_, ..., typeN_>& p);
07491
07492 #else // DOCUMENTATION_ONLY
07493
07494
07495 template<
07496 typename char_type_,
07497 typename traits_type_
07498 >
07499 std::basic_ostream<char_type_, traits_type_>&
07500 operator<<(
07501 std::basic_ostream<char_type_, traits_type_>& os,
07502 const pack<>& p)
07503 {
07504 std::streamsize width = os.width();
07505 bool punct = (os.flags() & std::ios_base::boolalpha) != 0;
07506
07507 os.width(0);
07508
07509 if (punct)
07510 os << '[';
07511
07512
07513 if (punct)
07514 os << ']';
07515 return os;
07516
07517 LITE_ARRAY_USE(p);
07518 }
07519
07520
07521 template<
07522 typename char_type_,
07523 typename traits_type_,
07524 typename type0_
07525 >
07526 std::basic_ostream<char_type_, traits_type_>&
07527 operator<<(
07528 std::basic_ostream<char_type_, traits_type_>& os,
07529 const pack<type0_>& p)
07530 {
07531 std::streamsize width = os.width();
07532 bool punct = (os.flags() & std::ios_base::boolalpha) != 0;
07533
07534 os.width(0);
07535
07536 if (punct)
07537 os << '[';
07538
07539 os.width(width); os << p.i0;
07540
07541 if (punct)
07542 os << ']';
07543 return os;
07544
07545 LITE_ARRAY_USE(p);
07546 }
07547
07548
07549 template<
07550 typename char_type_,
07551 typename traits_type_,
07552 typename type0_,
07553 typename type1_
07554 >
07555 std::basic_ostream<char_type_, traits_type_>&
07556 operator<<(
07557 std::basic_ostream<char_type_, traits_type_>& os,
07558 const pack<type0_,type1_>& p)
07559 {
07560 std::streamsize width = os.width();
07561 bool punct = (os.flags() & std::ios_base::boolalpha) != 0;
07562
07563 os.width(0);
07564
07565 if (punct)
07566 os << '[';
07567
07568 os.width(width); os << p.i0; os << ' ';
07569 os.width(width); os << p.i1;
07570
07571 if (punct)
07572 os << ']';
07573 return os;
07574
07575 LITE_ARRAY_USE(p);
07576 }
07577
07578
07579 template<
07580 typename char_type_,
07581 typename traits_type_,
07582 typename type0_,
07583 typename type1_,
07584 typename type2_
07585 >
07586 std::basic_ostream<char_type_, traits_type_>&
07587 operator<<(
07588 std::basic_ostream<char_type_, traits_type_>& os,
07589 const pack<type0_,type1_,type2_>& p)
07590 {
07591 std::streamsize width = os.width();
07592 bool punct = (os.flags() & std::ios_base::boolalpha) != 0;
07593
07594 os.width(0);
07595
07596 if (punct)
07597 os << '[';
07598
07599 os.width(width); os << p.i0; os << ' ';
07600 os.width(width); os << p.i1; os << ' ';
07601 os.width(width); os << p.i2;
07602
07603 if (punct)
07604 os << ']';
07605 return os;
07606
07607 LITE_ARRAY_USE(p);
07608 }
07609
07610
07611 template<
07612 typename char_type_,
07613 typename traits_type_,
07614 typename type0_,
07615 typename type1_,
07616 typename type2_,
07617 typename type3_
07618 >
07619 std::basic_ostream<char_type_, traits_type_>&
07620 operator<<(
07621 std::basic_ostream<char_type_, traits_type_>& os,
07622 const pack<type0_,type1_,type2_,type3_>& p)
07623 {
07624 std::streamsize width = os.width();
07625 bool punct = (os.flags() & std::ios_base::boolalpha) != 0;
07626
07627 os.width(0);
07628
07629 if (punct)
07630 os << '[';
07631
07632 os.width(width); os << p.i0; os << ' ';
07633 os.width(width); os << p.i1; os << ' ';
07634 os.width(width); os << p.i2; os << ' ';
07635 os.width(width); os << p.i3;
07636
07637 if (punct)
07638 os << ']';
07639 return os;
07640
07641 LITE_ARRAY_USE(p);
07642 }
07643
07644
07645 #endif // !DOCUMENTATION_ONLY
07646
07647
07648
07649
07650 #ifdef DOCUMENTATION_ONLY
07651
07677 template<typename char_type_, typename traits_type_, typename type0_, ..., typename typeN_>
07678 std::basic_istream<char_type_, traits_type_>&
07679 operator>>(
07680 std::basic_istream<char_type_, traits_type_>& is,
07681 pack<type0_, ..., typeN_>& p);
07682
07683 #else // DOCUMENTATION_ONLY
07684
07685
07686 template<
07687 typename char_type_,
07688 typename traits_type_
07689 >
07690 std::basic_istream<char_type_, traits_type_>&
07691 operator>>(
07692 std::basic_ostream<char_type_, traits_type_>& is,
07693 pack<>& p)
07694 {
07695 char_type_ ch;
07696
07697 if (!(is >> ch))
07698 return is;
07699
07700 bool fancy = is.narrow(ch, '\0') == '[';
07701
07702 if (!fancy)
07703 is.putback(ch);
07704
07705
07706 ch = char_type_();
07707 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
07708 is.setstate(std::ios_base::failbit);
07709 return is;
07710 }
07711
07712 p.set();
07713 return is;
07714 LITE_ARRAY_USE(p);
07715 }
07716
07717
07718 template<
07719 typename char_type_,
07720 typename traits_type_,
07721 typename type0_
07722 >
07723 std::basic_istream<char_type_, traits_type_>&
07724 operator>>(
07725 std::basic_ostream<char_type_, traits_type_>& is,
07726 pack<type0_>& p)
07727 {
07728 char_type_ ch;
07729
07730 if (!(is >> ch))
07731 return is;
07732
07733 bool fancy = is.narrow(ch, '\0') == '[';
07734
07735 if (!fancy)
07736 is.putback(ch);
07737
07738 type0_ i0; is >> i0;
07739
07740 ch = char_type_();
07741 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
07742 is.setstate(std::ios_base::failbit);
07743 return is;
07744 }
07745
07746 p.set(i0);
07747 return is;
07748 }
07749
07750
07751 template<
07752 typename char_type_,
07753 typename traits_type_,
07754 typename type0_,
07755 typename type1_
07756 >
07757 std::basic_istream<char_type_, traits_type_>&
07758 operator>>(
07759 std::basic_ostream<char_type_, traits_type_>& is,
07760 pack<type0_,type1_>& p)
07761 {
07762 char_type_ ch;
07763
07764 if (!(is >> ch))
07765 return is;
07766
07767 bool fancy = is.narrow(ch, '\0') == '[';
07768
07769 if (!fancy)
07770 is.putback(ch);
07771
07772 type0_ i0; is >> i0;
07773 type1_ i1; is >> i1;
07774
07775 ch = char_type_();
07776 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
07777 is.setstate(std::ios_base::failbit);
07778 return is;
07779 }
07780
07781 p.set(i0, i1);
07782 return is;
07783 }
07784
07785
07786 template<
07787 typename char_type_,
07788 typename traits_type_,
07789 typename type0_,
07790 typename type1_,
07791 typename type2_
07792 >
07793 std::basic_istream<char_type_, traits_type_>&
07794 operator>>(
07795 std::basic_ostream<char_type_, traits_type_>& is,
07796 pack<type0_,type1_,type2_>& p)
07797 {
07798 char_type_ ch;
07799
07800 if (!(is >> ch))
07801 return is;
07802
07803 bool fancy = is.narrow(ch, '\0') == '[';
07804
07805 if (!fancy)
07806 is.putback(ch);
07807
07808 type0_ i0; is >> i0;
07809 type1_ i1; is >> i1;
07810 type2_ i2; is >> i2;
07811
07812 ch = char_type_();
07813 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
07814 is.setstate(std::ios_base::failbit);
07815 return is;
07816 }
07817
07818 p.set(i0, i1, i2);
07819 return is;
07820 }
07821
07822
07823 template<
07824 typename char_type_,
07825 typename traits_type_,
07826 typename type0_,
07827 typename type1_,
07828 typename type2_,
07829 typename type3_
07830 >
07831 std::basic_istream<char_type_, traits_type_>&
07832 operator>>(
07833 std::basic_ostream<char_type_, traits_type_>& is,
07834 pack<type0_,type1_,type2_,type3_>& p)
07835 {
07836 char_type_ ch;
07837
07838 if (!(is >> ch))
07839 return is;
07840
07841 bool fancy = is.narrow(ch, '\0') == '[';
07842
07843 if (!fancy)
07844 is.putback(ch);
07845
07846 type0_ i0; is >> i0;
07847 type1_ i1; is >> i1;
07848 type2_ i2; is >> i2;
07849 type3_ i3; is >> i3;
07850
07851 ch = char_type_();
07852 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
07853 is.setstate(std::ios_base::failbit);
07854 return is;
07855 }
07856
07857 p.set(i0, i1, i2, i3);
07858 return is;
07859 }
07860
07861
07862 #endif // !DOCUMENTATION_ONLY
07863
07864
07865
07866
07867
07872 template<typename left_size_type_, typename right_size_type_>
07873 void lite_array_size_check(const left_size_type_& a, const right_size_type_& b, const std::string& msg)
07874 {
07875 if (a != b)
07876 throw size_mismatch_error(msg);
07877 }
07878
07879 }
07880
07881
07882
07883
07884
07885 namespace std
07886 {
07887 template<
07888 typename type0_,
07889 typename type1_,
07890 typename type2_,
07891 typename type3_
07892 >
07893 struct iterator_traits<lite::pack<
07894 type0_,
07895 type1_,
07896 type2_,
07897 type3_
07898 > >
07899 : public iterator_traits<type0_>
07900 {};
07901 }
07902
07903 namespace lite
07904 {
07905
07906
07907
07908
07909
07947
07948
07949
07950
07951 template<
07952 typename iter_type_
07953 >
07954 LITE_INLINE
07955 typename std::iterator_traits<pack<
07956 iter_type_
07957 > >::reference
07958 at(const pack<
07959 iter_type_
07960 >& it
07961 )
07962 {
07963 return *(it.i0);
07964 }
07965 template<
07966 typename iter_type_,
07967 typename ind_type0_
07968 >
07969 LITE_INLINE
07970 typename std::iterator_traits<pack<
07971 iter_type_,
07972 ind_type0_
07973 > >::reference
07974 at(const pack<
07975 iter_type_,
07976 ind_type0_
07977 >& it
07978 )
07979 {
07980 return *(it.i0);
07981 }
07982 template<
07983 typename iter_type_,
07984 typename ind_type0_
07985 >
07986 LITE_INLINE
07987 typename std::iterator_traits<pack<
07988 iter_type_,
07989 ind_type0_
07990 > >::reference
07991 at(const pack<
07992 iter_type_,
07993 ind_type0_
07994 >& it,
07995 int ind0
07996 )
07997 {
07998 return *(it.i0+ind0*it.i1);
07999 }
08000 template<
08001 typename iter_type_,
08002 typename ind_type0_,
08003 typename ind_type1_
08004 >
08005 LITE_INLINE
08006 typename std::iterator_traits<pack<
08007 iter_type_,
08008 ind_type0_,
08009 ind_type1_
08010 > >::reference
08011 at(const pack<
08012 iter_type_,
08013 ind_type0_,
08014 ind_type1_
08015 >& it
08016 )
08017 {
08018 return *(it.i0);
08019 }
08020 template<
08021 typename iter_type_,
08022 typename ind_type0_,
08023 typename ind_type1_
08024 >
08025 LITE_INLINE
08026 typename std::iterator_traits<pack<
08027 iter_type_,
08028 ind_type0_,
08029 ind_type1_
08030 > >::reference
08031 at(const pack<
08032 iter_type_,
08033 ind_type0_,
08034 ind_type1_
08035 >& it,
08036 int ind0
08037 )
08038 {
08039 return *(it.i0+ind0*it.i2);
08040 }
08041 template<
08042 typename iter_type_,
08043 typename ind_type0_,
08044 typename ind_type1_
08045 >
08046 LITE_INLINE
08047 typename std::iterator_traits<pack<
08048 iter_type_,
08049 ind_type0_,
08050 ind_type1_
08051 > >::reference
08052 at(const pack<
08053 iter_type_,
08054 ind_type0_,
08055 ind_type1_
08056 >& it,
08057 int ind0,
08058 int ind1
08059 )
08060 {
08061 return *(it.i0+ind0*it.i1+ind1*it.i2);
08062 }
08063 template<
08064 typename iter_type_,
08065 typename ind_type0_,
08066 typename ind_type1_,
08067 typename ind_type2_
08068 >
08069 LITE_INLINE
08070 typename std::iterator_traits<pack<
08071 iter_type_,
08072 ind_type0_,
08073 ind_type1_,
08074 ind_type2_
08075 > >::reference
08076 at(const pack<
08077 iter_type_,
08078 ind_type0_,
08079 ind_type1_,
08080 ind_type2_
08081 >& it
08082 )
08083 {
08084 return *(it.i0);
08085 }
08086 template<
08087 typename iter_type_,
08088 typename ind_type0_,
08089 typename ind_type1_,
08090 typename ind_type2_
08091 >
08092 LITE_INLINE
08093 typename std::iterator_traits<pack<
08094 iter_type_,
08095 ind_type0_,
08096 ind_type1_,
08097 ind_type2_
08098 > >::reference
08099 at(const pack<
08100 iter_type_,
08101 ind_type0_,
08102 ind_type1_,
08103 ind_type2_
08104 >& it,
08105 int ind0
08106 )
08107 {
08108 return *(it.i0+ind0*it.i3);
08109 }
08110 template<
08111 typename iter_type_,
08112 typename ind_type0_,
08113 typename ind_type1_,
08114 typename ind_type2_
08115 >
08116 LITE_INLINE
08117 typename std::iterator_traits<pack<
08118 iter_type_,
08119 ind_type0_,
08120 ind_type1_,
08121 ind_type2_
08122 > >::reference
08123 at(const pack<
08124 iter_type_,
08125 ind_type0_,
08126 ind_type1_,
08127 ind_type2_
08128 >& it,
08129 int ind0,
08130 int ind1
08131 )
08132 {
08133 return *(it.i0+ind0*it.i2+ind1*it.i3);
08134 }
08135 template<
08136 typename iter_type_,
08137 typename ind_type0_,
08138 typename ind_type1_,
08139 typename ind_type2_
08140 >
08141 LITE_INLINE
08142 typename std::iterator_traits<pack<
08143 iter_type_,
08144 ind_type0_,
08145 ind_type1_,
08146 ind_type2_
08147 > >::reference
08148 at(const pack<
08149 iter_type_,
08150 ind_type0_,
08151 ind_type1_,
08152 ind_type2_
08153 >& it,
08154 int ind0,
08155 int ind1,
08156 int ind2
08157 )
08158 {
08159 return *(it.i0+ind0*it.i1+ind1*it.i2+ind2*it.i3);
08160 }
08161
08162
08163
08164
08165
08166 template<
08167 int dim_,
08168 typename iter_type_,
08169 typename ind_type0_,
08170 typename ind_type1_,
08171 typename ind_type2_
08172 >
08173 LITE_INLINE
08174 typename detail::enable_if<dim_==0, void>::type
08175 inc(pack<
08176 iter_type_,
08177 ind_type0_,
08178 ind_type1_,
08179 ind_type2_
08180 >& it)
08181 {
08182 it.i0 += it.i1;
08183 }
08184
08185 template<
08186 int dim_,
08187 typename iter_type_,
08188 typename ind_type0_,
08189 typename ind_type1_,
08190 typename ind_type2_
08191 >
08192 LITE_INLINE
08193 typename detail::enable_if<dim_==1, void>::type
08194 inc(pack<
08195 iter_type_,
08196 ind_type0_,
08197 ind_type1_,
08198 ind_type2_
08199 >& it)
08200 {
08201 it.i0 += it.i2;
08202 }
08203
08204 template<
08205 int dim_,
08206 typename iter_type_,
08207 typename ind_type0_,
08208 typename ind_type1_,
08209 typename ind_type2_
08210 >
08211 LITE_INLINE
08212 typename detail::enable_if<dim_==2, void>::type
08213 inc(pack<
08214 iter_type_,
08215 ind_type0_,
08216 ind_type1_,
08217 ind_type2_
08218 >& it)
08219 {
08220 it.i0 += it.i3;
08221 }
08222
08223
08224
08225
08226
08227
08228 template<
08229 int dim_,
08230 typename iter_type_,
08231 typename ind_type0_,
08232 typename ind_type1_,
08233 typename ind_type2_
08234 >
08235 LITE_INLINE
08236 typename detail::enable_if<dim_==0, void>::type
08237 dec(pack<
08238 iter_type_,
08239 ind_type0_,
08240 ind_type1_,
08241 ind_type2_
08242 >& it)
08243 {
08244 it.i0 -= it.i1;
08245 }
08246
08247 template<
08248 int dim_,
08249 typename iter_type_,
08250 typename ind_type0_,
08251 typename ind_type1_,
08252 typename ind_type2_
08253 >
08254 LITE_INLINE
08255 typename detail::enable_if<dim_==1, void>::type
08256 dec(pack<
08257 iter_type_,
08258 ind_type0_,
08259 ind_type1_,
08260 ind_type2_
08261 >& it)
08262 {
08263 it.i0 -= it.i2;
08264 }
08265
08266 template<
08267 int dim_,
08268 typename iter_type_,
08269 typename ind_type0_,
08270 typename ind_type1_,
08271 typename ind_type2_
08272 >
08273 LITE_INLINE
08274 typename detail::enable_if<dim_==2, void>::type
08275 dec(pack<
08276 iter_type_,
08277 ind_type0_,
08278 ind_type1_,
08279 ind_type2_
08280 >& it)
08281 {
08282 it.i0 -= it.i3;
08283 }
08284
08285
08286
08287
08288
08289
08290 template<
08291 int dim_,
08292 typename iter_type_,
08293 typename ind_type0_,
08294 typename ind_type1_,
08295 typename ind_type2_
08296 >
08297 LITE_INLINE
08298 typename detail::enable_if<dim_==0, void>::type
08299 shift(pack<
08300 iter_type_,
08301 ind_type0_,
08302 ind_type1_,
08303 ind_type2_
08304 >& it,
08305 int diff)
08306 {
08307 it.i0 += diff*it.i1;
08308 }
08309
08310 template<
08311 int dim_,
08312 typename iter_type_,
08313 typename ind_type0_,
08314 typename ind_type1_,
08315 typename ind_type2_
08316 >
08317 LITE_INLINE
08318 typename detail::enable_if<dim_==1, void>::type
08319 shift(pack<
08320 iter_type_,
08321 ind_type0_,
08322 ind_type1_,
08323 ind_type2_
08324 >& it,
08325 int diff)
08326 {
08327 it.i0 += diff*it.i2;
08328 }
08329
08330 template<
08331 int dim_,
08332 typename iter_type_,
08333 typename ind_type0_,
08334 typename ind_type1_,
08335 typename ind_type2_
08336 >
08337 LITE_INLINE
08338 typename detail::enable_if<dim_==2, void>::type
08339 shift(pack<
08340 iter_type_,
08341 ind_type0_,
08342 ind_type1_,
08343 ind_type2_
08344 >& it,
08345 int diff)
08346 {
08347 it.i0 += diff*it.i3;
08348 }
08349
08350
08351
08352
08353
08354
08387 template<class value_type_>
08388 class c_iterator
08389 {
08390 public:
08391 typedef std::random_access_iterator_tag iterator_category;
08392 typedef value_type_ value_type;
08393 typedef ptrdiff_t difference_type;
08394 typedef const value_type_* pointer;
08395 typedef const value_type_& reference;
08396
08397 LITE_INLINE c_iterator() {}
08398
08400 LITE_INLINE c_iterator(const value_type& value) : value(value) {}
08401
08402 LITE_INLINE c_iterator(const c_iterator& other) : value(other.value) {}
08403
08404 template<class other_value_type_>
08405 LITE_INLINE c_iterator(const c_iterator<other_value_type_>& other) : value(other.value) {}
08406
08407 LITE_INLINE c_iterator& operator=(const c_iterator& other)
08408 {
08409 value = other.value;
08410 return *this;
08411 }
08412
08413 template<class other_value_type_>
08414 LITE_INLINE c_iterator& operator=(const c_iterator<other_value_type_>& other)
08415 {
08416 value = other.value;
08417 return *this;
08418 }
08419
08421 value_type value;
08422 };
08423
08429 template<class value_type_>
08430 LITE_INLINE c_iterator<value_type_>
08431 make_c_iterator(const value_type_& val)
08432 {
08433 return c_iterator<value_type_>(val);
08434 }
08435
08436
08437
08438
08439
08440 template<typename value_type_>
08441 LITE_INLINE
08442 typename std::iterator_traits<c_iterator<value_type_> >::reference
08443 at(const c_iterator<value_type_>& it )
08444 {
08445 return it.value;
08446 }
08447 template<typename value_type_>
08448 LITE_INLINE
08449 typename std::iterator_traits<c_iterator<value_type_> >::reference
08450 at(const c_iterator<value_type_>& it, int )
08451 {
08452 return it.value;
08453 }
08454 template<typename value_type_>
08455 LITE_INLINE
08456 typename std::iterator_traits<c_iterator<value_type_> >::reference
08457 at(const c_iterator<value_type_>& it, int , int )
08458 {
08459 return it.value;
08460 }
08461 template<typename value_type_>
08462 LITE_INLINE
08463 typename std::iterator_traits<c_iterator<value_type_> >::reference
08464 at(const c_iterator<value_type_>& it, int , int , int )
08465 {
08466 return it.value;
08467 }
08468
08469
08470
08471
08472
08473 template<int dim_, typename value_type_>
08474 LITE_INLINE void inc(c_iterator<value_type_>&) {}
08475
08476
08477
08478
08479
08480 template<int dim_, typename value_type_>
08481 LITE_INLINE void dec(c_iterator<value_type_>&) {}
08482
08483
08484
08485
08486
08487 template<int dim_, typename value_type_>
08488 LITE_INLINE void shift(c_iterator<value_type_>&, int) {}
08489
08490
08491
08492
08493
08494 #ifdef DOCUMENTATION_ONLY
08495
08538 template<typename base_iter_type_, typename func_type_, bool is_static_ =true>
08539 class u_iterator
08540 {
08541 public:
08542 typedef base_iter_type_ base_iterator_type;
08543 typedef func_type_ function_type;
08544 static const bool is_static = is_static_;
08545
08546 typedef std::random_access_iterator_tag iterator_category;
08547 typedef typename detail::remove<typename func_type_::result_type, const volatile int&>::type value_type;
08548 typedef ptrdiff_t difference_type;
08549 typedef typename func_type_::result_type reference;
08550 typedef typename detail::remove<typename func_type_::result_type, int&>::type* pointer;
08551
08552 LITE_INLINE u_iterator();
08553
08555 template<class other_base_iter_type_>
08556 LITE_INLINE u_iterator(const other_base_iter_type_& base_iter);
08557
08563 template<class other_base_iter_type_>
08564 LITE_INLINE u_iterator(const other_base_iter_type_& base_iter, const function_type& func);
08565
08566 LITE_INLINE u_iterator(const u_iterator& other);
08567
08568 template<class other_base_iter_type_>
08569 LITE_INLINE u_iterator(const u_iterator<other_base_iter_type_, func_type_, is_static_>& other);
08570
08571 LITE_INLINE u_iterator& operator=(const u_iterator& other);
08572
08573 template<typename other_base_iter_type_>
08574 LITE_INLINE u_iterator& operator=(const u_iterator<other_base_iter_type_, func_type_, is_static_>& other);
08575
08577 base_iterator_type base_iterator;
08578
08580 function_type function;
08581 };
08582
08583 #endif // DOCUMENTATION_ONLY
08584
08585
08586
08587
08588
08589 #ifndef DOCUMENTATION_ONLY
08590
08591 template<typename base_iter_type_, typename func_type_>
08592 class u_iterator<base_iter_type_, func_type_, true>
08593 {
08594 public:
08595 typedef base_iter_type_ base_iterator_type;
08596 typedef func_type_ function_type;
08597 static const bool is_static = true;
08598
08599 typedef std::random_access_iterator_tag iterator_category;
08600 typedef typename detail::remove<typename func_type_::result_type, const volatile int&>::type value_type;
08601 typedef ptrdiff_t difference_type;
08602 typedef typename func_type_::result_type reference;
08603 typedef typename detail::remove<typename func_type_::result_type, int&>::type* pointer;
08604
08605 LITE_INLINE u_iterator() {}
08606
08607 template<class other_base_iter_type_>
08608 LITE_INLINE u_iterator(const other_base_iter_type_& base_iter)
08609 : base_iterator(base_iter) {}
08610
08611 LITE_INLINE u_iterator(const u_iterator& other)
08612 : base_iterator(other.base_iterator) {}
08613
08614 template<class other_base_iter_type_>
08615 LITE_INLINE u_iterator(const u_iterator<other_base_iter_type_, func_type_, true>& other)
08616 : base_iterator(other.base_iterator) {}
08617
08618 LITE_INLINE u_iterator& operator=(const u_iterator& other)
08619 {
08620 base_iterator = other.base_iterator;
08621 return *this;
08622 }
08623
08624 template<typename other_base_iter_type_>
08625 LITE_INLINE u_iterator& operator=(const u_iterator<other_base_iter_type_, func_type_, true>& other)
08626 {
08627 base_iterator = other.base_iterator;
08628 return *this;
08629 }
08630
08631 base_iterator_type base_iterator;
08632 static function_type function;
08633 };
08634
08635 template<typename base_iter_type_, typename func_type_>
08636 typename u_iterator<base_iter_type_, func_type_, true>::function_type
08637 u_iterator<base_iter_type_, func_type_, true>::function;
08638
08639 #endif // !DOCUMENTATION_ONLY
08640
08648 template<typename func_type_, typename base_iter_type_>
08649 LITE_INLINE u_iterator<base_iter_type_, func_type_, true>
08650 make_u_iterator(const base_iter_type_& it)
08651 {
08652 return u_iterator<base_iter_type_, func_type_, true>(it);
08653 }
08654
08655
08656
08657
08658
08659 #ifndef DOCUMENTATION_ONLY
08660
08661 template<typename base_iter_type_, typename func_type_>
08662 class u_iterator<base_iter_type_, func_type_, false>
08663 {
08664 public:
08665 typedef base_iter_type_ base_iterator_type;
08666 typedef func_type_ function_type;
08667 static const bool is_static = false;
08668
08669 typedef std::random_access_iterator_tag iterator_category;
08670 typedef typename detail::remove<typename func_type_::result_type, const volatile int&>::type value_type;
08671 typedef ptrdiff_t difference_type;
08672 typedef typename func_type_::result_type reference;
08673 typedef typename detail::remove<typename func_type_::result_type, int&>::type* pointer;
08674
08675 LITE_INLINE u_iterator() {}
08676
08677 template<class other_base_iter_type_>
08678 LITE_INLINE u_iterator(const other_base_iter_type_& base_iter, const function_type& func =function_type())
08679 : base_iterator(base_iter), function(func) {}
08680
08681 LITE_INLINE u_iterator(const u_iterator& other)
08682 : base_iterator(other.base_iterator), function(other.function) {}
08683
08684 template<typename other_base_iter_type_>
08685 LITE_INLINE u_iterator(const u_iterator<other_base_iter_type_, func_type_, false>& other)
08686 : base_iterator(other.base_iterator), function(other.function) {}
08687
08688 LITE_INLINE u_iterator& operator=(const u_iterator& other)
08689 {
08690 base_iterator = other.base_iterator;
08691 function = other.function;
08692 return *this;
08693 }
08694
08695 template<typename other_base_iter_type_>
08696 LITE_INLINE u_iterator& operator=(const u_iterator<other_base_iter_type_, func_type_, false>& other)
08697 {
08698 base_iterator = other.base_iterator;
08699 function = other.function;
08700 return *this;
08701 }
08702
08703 base_iterator_type base_iterator;
08704 function_type function;
08705 };
08706
08707 #endif // !DOCUMENTATION_ONLY
08708
08714 template<typename func_type_, typename base_iter_type_>
08715 LITE_INLINE u_iterator<base_iter_type_, func_type_, false>
08716 make_u_iterator(const base_iter_type_& it, const func_type_& func)
08717 {
08718 return u_iterator<base_iter_type_, func_type_, false>(it, func);
08719 }
08720
08721
08722
08723
08724
08725 template<typename base_iter_type_, typename func_type_, bool is_static_>
08726 LITE_INLINE
08727 typename u_iterator<base_iter_type_, func_type_, is_static_>::reference
08728 at(const u_iterator<base_iter_type_, func_type_, is_static_>& it
08729 )
08730 {
08731 return it.function(at(it.base_iterator
08732 ));
08733 }
08734 template<typename base_iter_type_, typename func_type_, bool is_static_>
08735 LITE_INLINE
08736 typename u_iterator<base_iter_type_, func_type_, is_static_>::reference
08737 at(const u_iterator<base_iter_type_, func_type_, is_static_>& it,
08738 int ind0
08739 )
08740 {
08741 return it.function(at(it.base_iterator,
08742 ind0
08743 ));
08744 }
08745 template<typename base_iter_type_, typename func_type_, bool is_static_>
08746 LITE_INLINE
08747 typename u_iterator<base_iter_type_, func_type_, is_static_>::reference
08748 at(const u_iterator<base_iter_type_, func_type_, is_static_>& it,
08749 int ind0,
08750 int ind1
08751 )
08752 {
08753 return it.function(at(it.base_iterator,
08754 ind0,
08755 ind1
08756 ));
08757 }
08758 template<typename base_iter_type_, typename func_type_, bool is_static_>
08759 LITE_INLINE
08760 typename u_iterator<base_iter_type_, func_type_, is_static_>::reference
08761 at(const u_iterator<base_iter_type_, func_type_, is_static_>& it,
08762 int ind0,
08763 int ind1,
08764 int ind2
08765 )
08766 {
08767 return it.function(at(it.base_iterator,
08768 ind0,
08769 ind1,
08770 ind2
08771 ));
08772 }
08773
08774
08775
08776
08777
08778 template<int dim_, typename base_iter_type_, typename func_type_, bool is_static_>
08779 LITE_INLINE void inc(u_iterator<base_iter_type_, func_type_, is_static_>& it)
08780 {
08781 inc<dim_>(it.base_iterator);
08782 }
08783
08784
08785
08786
08787
08788 template<int dim_, typename base_iter_type_, typename func_type_, bool is_static_>
08789 LITE_INLINE void dec(u_iterator<base_iter_type_, func_type_, is_static_>& it)
08790 {
08791 dec<dim_>(it.base_iterator);
08792 }
08793
08794
08795
08796
08797
08798 template<int dim_, typename base_iter_type_, typename func_type_, bool is_static_>
08799 LITE_INLINE void shift(u_iterator<base_iter_type_, func_type_, is_static_>& it, int diff)
08800 {
08801 shift<dim_>(it.base_iterator, diff);
08802 }
08803
08804
08805
08806
08807
08808 #ifdef DOCUMENTATION_ONLY
08809
08857 template<
08858 typename left_base_iterator_type_,
08859 typename right_base_iterator_type_,
08860 typename func_type_,
08861 bool is_static_ =true>
08862 class b_iterator
08863 {
08864 public:
08865 typedef left_base_iterator_type_ left_base_iterator_type;
08866 typedef right_base_iterator_type_ right_base_iterator_type;
08867 typedef func_type_ function_type;
08868 static const bool is_static = is_static_;
08869
08870 typedef std::random_access_iterator_tag iterator_category;
08871 typedef typename detail::remove<typename func_type_::result_type, const volatile int&>::type value_type;
08872 typedef ptrdiff_t difference_type;
08873 typedef typename func_type_::result_type reference;
08874 typedef typename detail::remove<typename func_type_::result_type, int&>::type* pointer;
08875
08876 LITE_INLINE b_iterator() {}
08877
08878
08880 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
08881 LITE_INLINE b_iterator(
08882 const other_left_base_iterator_type_& lbase_iter,
08883 const other_right_base_iterator_type_& rbase_iter);
08884
08885 LITE_INLINE b_iterator(const b_iterator& other);
08886
08894 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
08895 LITE_INLINE b_iterator(
08896 const b_iterator<
08897 other_left_base_iterator_type_,
08898 other_right_base_iterator_type_,
08899 func_type_,
08900 is_static_>& other);
08901
08902 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
08903 LITE_INLINE b_iterator(
08904 const other_left_base_iterator_type_& lbase_iter,
08905 const other_right_base_iterator_type_& rbase_iter,
08906 const function_type& func);
08907
08908
08909 LITE_INLINE b_iterator& operator=(const b_iterator& other);
08910
08911 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
08912 LITE_INLINE b_iterator&
08913 operator=(const b_iterator<
08914 other_left_base_iterator_type_,
08915 other_right_base_iterator_type_,
08916 func_type_,
08917 is_static_>& other);
08918
08920 left_base_iterator_type left_base_iterator;
08921
08923 right_base_iterator_type right_base_iterator;
08924
08926 function_type function;
08927 };
08928
08929
08930 #endif // DOCUMENTATION_ONLY
08931
08932
08933
08934
08935
08936 #ifndef DOCUMENTATION_ONLY
08937
08938 template<typename left_base_iterator_type_, typename right_base_iterator_type_, typename func_type_>
08939 class b_iterator<left_base_iterator_type_, right_base_iterator_type_, func_type_, true>
08940 {
08941 public:
08942 typedef left_base_iterator_type_ left_base_iterator_type;
08943 typedef right_base_iterator_type_ right_base_iterator_type;
08944 typedef func_type_ function_type;
08945 static const bool is_static = true;
08946
08947 typedef std::random_access_iterator_tag iterator_category;
08948 typedef typename detail::remove<typename func_type_::result_type, const volatile int&>::type value_type;
08949 typedef ptrdiff_t difference_type;
08950 typedef typename func_type_::result_type reference;
08951 typedef typename detail::remove<typename func_type_::result_type, int&>::type* pointer;
08952
08953 LITE_INLINE b_iterator() {}
08954
08955 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
08956 LITE_INLINE b_iterator(
08957 const other_left_base_iterator_type_& lbase_iter,
08958 const other_right_base_iterator_type_& rbase_iter)
08959 : left_base_iterator(lbase_iter), right_base_iterator(rbase_iter) {}
08960
08961 LITE_INLINE b_iterator(const b_iterator& other)
08962 : left_base_iterator(other.left_base_iterator),
08963 right_base_iterator(other.right_base_iterator)
08964 {}
08965
08966 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
08967 LITE_INLINE b_iterator(
08968 const b_iterator<
08969 other_left_base_iterator_type_,
08970 other_right_base_iterator_type_,
08971 func_type_,
08972 true>& other)
08973 : left_base_iterator(other.left_base_iterator),
08974 right_base_iterator(other.right_base_iterator)
08975 {}
08976
08977 LITE_INLINE b_iterator& operator=(const b_iterator& other)
08978 {
08979 left_base_iterator = other.left_base_iterator;
08980 right_base_iterator = other.right_base_iterator;
08981 return *this;
08982 }
08983
08984 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
08985 LITE_INLINE b_iterator&
08986 operator=(const b_iterator<
08987 other_left_base_iterator_type_,
08988 other_right_base_iterator_type_,
08989 func_type_,
08990 true>& other)
08991 {
08992 left_base_iterator = other.left_base_iterator;
08993 right_base_iterator = other.right_base_iterator;
08994 return *this;
08995 }
08996
08997 left_base_iterator_type left_base_iterator;
08998 right_base_iterator_type right_base_iterator;
08999 static function_type function;
09000 };
09001
09002 template<typename left_base_iterator_type_, typename right_base_iterator_type_, typename func_type_>
09003 typename b_iterator<left_base_iterator_type_, right_base_iterator_type_, func_type_, true>::function_type
09004 b_iterator<left_base_iterator_type_, right_base_iterator_type_, func_type_, true>::function;
09005
09006 #endif // !DOCUMENTATION_ONLY
09007
09015 template<typename func_type_, typename left_base_iterator_type_, typename right_base_iterator_type_>
09016 LITE_INLINE b_iterator<left_base_iterator_type_, right_base_iterator_type_, func_type_, true>
09017 make_b_iterator(
09018 const left_base_iterator_type_& left_it,
09019 const right_base_iterator_type_& right_it)
09020 {
09021 return b_iterator<left_base_iterator_type_, right_base_iterator_type_, func_type_, true>
09022 (left_it, right_it);
09023 }
09024
09025
09026
09027
09028
09029 #ifndef DOCUMENTATION_ONLY
09030
09031 template<typename left_base_iterator_type_, typename right_base_iterator_type_, typename func_type_>
09032 class b_iterator<left_base_iterator_type_, right_base_iterator_type_, func_type_, false>
09033 {
09034 public:
09035 typedef left_base_iterator_type_ left_base_iterator_type;
09036 typedef right_base_iterator_type_ right_base_iterator_type;
09037 typedef func_type_ function_type;
09038 static const bool is_static = false;
09039
09040 typedef std::random_access_iterator_tag iterator_category;
09041 typedef typename detail::remove<typename func_type_::result_type, const volatile int&>::type value_type;
09042 typedef ptrdiff_t difference_type;
09043 typedef typename func_type_::result_type reference;
09044 typedef typename detail::remove<typename func_type_::result_type, int&>::type* pointer;
09045
09046 LITE_INLINE b_iterator() {}
09047
09048 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
09049 LITE_INLINE b_iterator(
09050 const other_left_base_iterator_type_& lbase_iter,
09051 const other_right_base_iterator_type_& rbase_iter,
09052 const function_type& func = function_type())
09053 : left_base_iterator(lbase_iter), right_base_iterator(rbase_iter), function(func) {}
09054
09055 LITE_INLINE b_iterator(const b_iterator& other)
09056 : left_base_iterator(other.left_base_iterator),
09057 right_base_iterator(other.right_base_iterator),
09058 function(other.function)
09059 {}
09060
09061 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
09062 LITE_INLINE b_iterator(
09063 const b_iterator<
09064 other_left_base_iterator_type_,
09065 other_right_base_iterator_type_,
09066 func_type_,
09067 false>& other)
09068 : left_base_iterator(other.left_base_iterator),
09069 right_base_iterator(other.right_base_iterator),
09070 function(other.function)
09071 {}
09072
09073 LITE_INLINE b_iterator& operator=(const b_iterator& other)
09074 {
09075 left_base_iterator = other.left_base_iterator;
09076 right_base_iterator = other.right_base_iterator;
09077 function = other.function;
09078 return *this;
09079 }
09080
09081 template<typename other_left_base_iterator_type_, typename other_right_base_iterator_type_>
09082 LITE_INLINE b_iterator&
09083 operator=(const b_iterator<
09084 other_left_base_iterator_type_,
09085 other_right_base_iterator_type_,
09086 func_type_,
09087 false>& other)
09088 {
09089 left_base_iterator = other.left_base_iterator;
09090 right_base_iterator = other.right_base_iterator;
09091 function = other.function;
09092 return *this;
09093 }
09094
09095 left_base_iterator_type left_base_iterator;
09096 right_base_iterator_type right_base_iterator;
09097 function_type function;
09098 };
09099
09100 #endif // DOCUMENTATION_ONLY
09101
09109 template<typename func_type_, typename left_base_iterator_type_, typename right_base_iterator_type_>
09110 LITE_INLINE b_iterator<left_base_iterator_type_, right_base_iterator_type_, func_type_, false>
09111 make_b_iterator(
09112 const left_base_iterator_type_& left_it,
09113 const right_base_iterator_type_& right_it,
09114 const func_type_& func)
09115 {
09116 return b_iterator<left_base_iterator_type_, right_base_iterator_type_, func_type_, false>
09117 (left_it, right_it, func);
09118 }
09119
09120
09121
09122
09123
09124 template<typename left_base_iter_type_, typename right_base_iter_type_, typename func_type_, bool is_static_>
09125 LITE_INLINE
09126 typename b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>::reference
09127 at(const b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>& it
09128 )
09129 {
09130 return it.function(
09131 at(it.left_base_iterator
09132 ),
09133 at(it.right_base_iterator
09134 )
09135 );
09136 }
09137 template<typename left_base_iter_type_, typename right_base_iter_type_, typename func_type_, bool is_static_>
09138 LITE_INLINE
09139 typename b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>::reference
09140 at(const b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>& it,
09141 int ind0
09142 )
09143 {
09144 return it.function(
09145 at(it.left_base_iterator,
09146 ind0
09147 ),
09148 at(it.right_base_iterator,
09149 ind0
09150 )
09151 );
09152 }
09153 template<typename left_base_iter_type_, typename right_base_iter_type_, typename func_type_, bool is_static_>
09154 LITE_INLINE
09155 typename b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>::reference
09156 at(const b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>& it,
09157 int ind0,
09158 int ind1
09159 )
09160 {
09161 return it.function(
09162 at(it.left_base_iterator,
09163 ind0,
09164 ind1
09165 ),
09166 at(it.right_base_iterator,
09167 ind0,
09168 ind1
09169 )
09170 );
09171 }
09172 template<typename left_base_iter_type_, typename right_base_iter_type_, typename func_type_, bool is_static_>
09173 LITE_INLINE
09174 typename b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>::reference
09175 at(const b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>& it,
09176 int ind0,
09177 int ind1,
09178 int ind2
09179 )
09180 {
09181 return it.function(
09182 at(it.left_base_iterator,
09183 ind0,
09184 ind1,
09185 ind2
09186 ),
09187 at(it.right_base_iterator,
09188 ind0,
09189 ind1,
09190 ind2
09191 )
09192 );
09193 }
09194
09195
09196
09197
09198
09199 template<
09200 int dim_,
09201 typename left_base_iter_type_,
09202 typename right_base_iter_type_,
09203 typename func_type_,
09204 bool is_static_>
09205 LITE_INLINE void inc(b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>& it)
09206 {
09207 inc<dim_>(it.left_base_iterator);
09208 inc<dim_>(it.right_base_iterator);
09209 }
09210
09211
09212
09213
09214
09215 template<
09216 int dim_,
09217 typename left_base_iter_type_,
09218 typename right_base_iter_type_,
09219 typename func_type_,
09220 bool is_static_>
09221 LITE_INLINE void dec(b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>& it)
09222 {
09223 dec<dim_>(it.left_base_iterator);
09224 dec<dim_>(it.right_base_iterator);
09225 }
09226
09227
09228
09229
09230
09231 template<
09232 int dim_,
09233 typename left_base_iter_type_,
09234 typename right_base_iter_type_,
09235 typename func_type_,
09236 bool is_static_>
09237 LITE_INLINE
09238 void shift(b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>& it, int diff)
09239 {
09240 shift<dim_>(it.left_base_iterator, diff);
09241 shift<dim_>(it.right_base_iterator, diff);
09242 }
09243
09244
09245
09246
09247
09248 #ifdef DOCUMENTATION_ONLY
09249
09259 template<typename transform_type_, typename input_size_type_>
09260 struct size_transformer
09261 {
09262 public:
09264 typedef ??? size_type;
09265
09274 static void transform(const input_size_type_& org, size_type& res);
09275
09279 static void transform(const transform_type& trans, const input_size_type_& org, size_type& res);
09280 };
09281
09282 #endif // DOCUMENTATION_ONLY
09283
09284
09285
09286
09287
09288 #ifdef DOCUMENTATION_ONLY
09289
09300 template<typename transform_type_, typename input_iterator_type_, typename input_size_type_>
09301 struct iterator_transformer
09302 {
09303 public:
09305 typedef ??? iterator_type;
09306
09316 static void transform(
09317 const input_iterator_type& org,
09318 iterator_type& res);
09319
09329 static void transform(
09330 const transform_type_& trans,
09331 const input_iterator_type& org,
09332 iterator_type& res);
09333
09339 static void transform(
09340 const transform_type_& trans,
09341 const input_iterator_type& org,
09342 const input_size_type_& sz,
09343 iterator_type& res);
09344 };
09345
09346 #endif // DOCUMENTATION_ONLY
09347
09348
09349
09350
09351
09352 template<typename transform_type_, typename value_type_, typename input_size_type_>
09353 struct iterator_transformer<transform_type_, c_iterator<value_type_>, input_size_type_>
09354 {
09355 public:
09356 typedef c_iterator<value_type_> input_iterator_type;
09357 typedef input_iterator_type iterator_type;
09358
09359 static LITE_INLINE void transform(
09360 const input_iterator_type& org,
09361 iterator_type& res)
09362 {
09363 res.value = org.value;
09364 }
09365
09366 static LITE_INLINE void transform(
09367 const transform_type_&,
09368 const input_iterator_type& org,
09369 iterator_type& res)
09370 {
09371 res.value = org.value;
09372 }
09373
09374 static LITE_INLINE void transform(
09375 const transform_type_&,
09376 const input_iterator_type& org,
09377 const input_size_type_&,
09378 iterator_type& res)
09379 {
09380 res.value = org.value;
09381 }
09382 };
09383
09384
09385
09386
09387
09388 template<
09389 typename transform_type_,
09390 typename base_iter_type_,
09391 typename func_type_,
09392 typename input_size_type_>
09393 struct iterator_transformer<
09394 transform_type_,
09395 u_iterator<base_iter_type_, func_type_, true>,
09396 input_size_type_>
09397 {
09398 public:
09399 typedef iterator_transformer<transform_type_, base_iter_type_, input_size_type_> base_transformer;
09400
09401 typedef u_iterator<base_iter_type_, func_type_, true> input_iterator_type;
09402 typedef u_iterator<typename base_transformer::iterator_type, func_type_, true> iterator_type;
09403
09404 static LITE_INLINE void transform(
09405 const input_iterator_type& org,
09406 iterator_type& res)
09407 {
09408 base_transformer::transform(org.base_iterator, res.base_iterator);
09409 }
09410
09411 static LITE_INLINE void transform(
09412 const transform_type_& trans,
09413 const input_iterator_type& org,
09414 iterator_type& res)
09415 {
09416 base_transformer::transform(trans, org.base_iterator, res.base_iterator);
09417 }
09418
09419 static LITE_INLINE void transform(
09420 const transform_type_& trans,
09421 const input_iterator_type& org,
09422 const input_size_type_& sz,
09423 iterator_type& res)
09424 {
09425 base_transformer::transform(trans, org.base_iterator, sz, res.base_iterator);
09426 }
09427 };
09428
09429
09430
09431 template<
09432 typename transform_type_,
09433 typename base_iter_type_,
09434 typename func_type_,
09435 typename input_size_type_>
09436 struct iterator_transformer<
09437 transform_type_,
09438 u_iterator<base_iter_type_, func_type_, false>,
09439 input_size_type_>
09440 {
09441 public:
09442 typedef iterator_transformer<transform_type_, base_iter_type_, input_size_type_> base_transformer;
09443
09444 typedef u_iterator<base_iter_type_, func_type_, false> input_iterator_type;
09445 typedef u_iterator<typename base_transformer::iterator_type, func_type_, false> iterator_type;
09446
09447 static LITE_INLINE void transform(
09448 const input_iterator_type& org,
09449 iterator_type& res)
09450 {
09451 base_transformer::transform(org.base_iterator, res.base_iterator);
09452 res.function = org.function;
09453 }
09454
09455 static LITE_INLINE void transform(
09456 const transform_type_& trans,
09457 const input_iterator_type& org,
09458 iterator_type& res)
09459 {
09460 base_transformer::transform(trans, org.base_iterator, res.base_iterator);
09461 res.function = org.function;
09462 }
09463
09464 static LITE_INLINE void transform(
09465 const transform_type_& trans,
09466 const input_iterator_type& org,
09467 const input_size_type_& sz,
09468 iterator_type& res)
09469 {
09470 base_transformer::transform(trans, org.base_iterator, sz, res.base_iterator);
09471 res.function = org.function;
09472 }
09473 };
09474
09475
09476
09477
09478
09479 template<
09480 typename transform_type_,
09481 typename left_base_iter_type_,
09482 typename right_base_iter_type_,
09483 typename func_type_,
09484 typename input_size_type_>
09485 struct iterator_transformer<
09486 transform_type_,
09487 b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, true>,
09488 input_size_type_>
09489 {
09490 public:
09491 typedef iterator_transformer<transform_type_, left_base_iter_type_, input_size_type_>
09492 left_base_transformer;
09493
09494 typedef iterator_transformer<transform_type_, right_base_iter_type_, input_size_type_>
09495 right_base_transformer;
09496
09497 typedef b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, true> input_iterator_type;
09498
09499 typedef b_iterator<
09500 typename left_base_transformer::iterator_type,
09501 typename right_base_transformer::iterator_type,
09502 func_type_,
09503 true>
09504 iterator_type;
09505
09506 static LITE_INLINE void transform(
09507 const input_iterator_type& org,
09508 iterator_type& res)
09509 {
09510 left_base_transformer::transform(org.left_base_iterator, res.left_base_iterator);
09511 right_base_transformer::transform(org.right_base_iterator, res.right_base_iterator);
09512 }
09513
09514 static LITE_INLINE void transform(
09515 const transform_type_& trans,
09516 const input_iterator_type& org,
09517 iterator_type& res)
09518 {
09519 left_base_transformer::transform(trans, org.left_base_iterator, res.left_base_iterator);
09520 right_base_transformer::transform(trans, org.right_base_iterator, res.right_base_iterator);
09521 }
09522
09523 static LITE_INLINE void transform(
09524 const transform_type_& trans,
09525 const input_iterator_type& org,
09526 const input_size_type_& sz,
09527 iterator_type& res)
09528 {
09529 left_base_transformer::transform(trans, org.left_base_iterator, sz, res.left_base_iterator);
09530 right_base_transformer::transform(trans, org.right_base_iterator, sz, res.right_base_iterator);
09531 }
09532 };
09533
09534
09535
09536 template<
09537 typename transform_type_,
09538 typename left_base_iter_type_,
09539 typename right_base_iter_type_,
09540 typename func_type_,
09541 typename input_size_type_>
09542 struct iterator_transformer<
09543 transform_type_,
09544 b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, false>,
09545 input_size_type_>
09546 {
09547 public:
09548 typedef iterator_transformer<transform_type_, left_base_iter_type_, input_size_type_>
09549 left_base_transformer;
09550
09551 typedef iterator_transformer<transform_type_, right_base_iter_type_, input_size_type_>
09552 right_base_transformer;
09553
09554 typedef b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, false> input_iterator_type;
09555
09556 typedef b_iterator<
09557 typename left_base_transformer::iterator_type,
09558 typename right_base_transformer::iterator_type,
09559 func_type_,
09560 false>
09561 iterator_type;
09562
09563 static LITE_INLINE void transform(
09564 const input_iterator_type& org,
09565 iterator_type& res)
09566 {
09567 left_base_transformer::transform(org.left_base_iterator, res.left_base_iterator);
09568 right_base_transformer::transform(org.right_base_iterator, res.right_base_iterator);
09569 res.function = org.function;
09570 }
09571
09572 static LITE_INLINE void transform(
09573 const transform_type_& trans,
09574 const input_iterator_type& org,
09575 iterator_type& res)
09576 {
09577 left_base_transformer::transform(trans, org.left_base_iterator, res.left_base_iterator);
09578 right_base_transformer::transform(trans, org.right_base_iterator, res.right_base_iterator);
09579 res.function = org.function;
09580 }
09581
09582 static LITE_INLINE void transform(
09583 const transform_type_& trans,
09584 const input_iterator_type& org,
09585 const input_size_type_& sz,
09586 iterator_type& res)
09587 {
09588 left_base_transformer::transform(trans, org.left_base_iterator, sz, res.left_base_iterator);
09589 right_base_transformer::transform(trans, org.right_base_iterator, sz, res.right_base_iterator);
09590 res.function = org.function;
09591 }
09592 };
09593
09594
09595
09596
09597
09622 template<int dim_>
09623 class plane
09624 {
09625 public:
09627 LITE_INLINE plane(int index =0) : index(index) {}
09628
09629 LITE_INLINE plane(const plane& other) : index(other.index) {}
09630
09631 LITE_INLINE plane& operator=(const plane& other) { index = other.index; return *this; }
09632
09634 int index;
09635 };
09636
09637
09638
09639
09640
09641 template<
09642 typename type0_
09643 >
09644 struct size_transformer<
09645 plane<0>,
09646 pack<
09647 type0_
09648 > >
09649 {
09650 public:
09651 typedef plane<0> transform_type;
09652
09653 typedef pack<
09654 type0_
09655 > input_size_type;
09656
09657 typedef sub_pack<
09658 input_size_type,
09659 false
09660 > sub_pack_type;
09661
09662 typedef typename sub_pack_type::type size_type;
09663
09664 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
09665 {
09666 sub_pack_type::set(res, org);
09667 }
09668
09669 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
09670 {
09671 sub_pack_type::set(res, org);
09672 }
09673 };
09674
09675
09676 template<
09677 typename type0_,
09678 typename type1_
09679 >
09680 struct size_transformer<
09681 plane<0>,
09682 pack<
09683 type0_,
09684 type1_
09685 > >
09686 {
09687 public:
09688 typedef plane<0> transform_type;
09689
09690 typedef pack<
09691 type0_,
09692 type1_
09693 > input_size_type;
09694
09695 typedef sub_pack<
09696 input_size_type,
09697 false,
09698 true
09699 > sub_pack_type;
09700
09701 typedef typename sub_pack_type::type size_type;
09702
09703 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
09704 {
09705 sub_pack_type::set(res, org);
09706 }
09707
09708 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
09709 {
09710 sub_pack_type::set(res, org);
09711 }
09712 };
09713
09714
09715 template<
09716 typename type0_,
09717 typename type1_,
09718 typename type2_
09719 >
09720 struct size_transformer<
09721 plane<0>,
09722 pack<
09723 type0_,
09724 type1_,
09725 type2_
09726 > >
09727 {
09728 public:
09729 typedef plane<0> transform_type;
09730
09731 typedef pack<
09732 type0_,
09733 type1_,
09734 type2_
09735 > input_size_type;
09736
09737 typedef sub_pack<
09738 input_size_type,
09739 false,
09740 true,
09741 true
09742 > sub_pack_type;
09743
09744 typedef typename sub_pack_type::type size_type;
09745
09746 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
09747 {
09748 sub_pack_type::set(res, org);
09749 }
09750
09751 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
09752 {
09753 sub_pack_type::set(res, org);
09754 }
09755 };
09756
09757
09758 template<
09759 typename type0_,
09760 typename type1_
09761 >
09762 struct size_transformer<
09763 plane<1>,
09764 pack<
09765 type0_,
09766 type1_
09767 > >
09768 {
09769 public:
09770 typedef plane<1> transform_type;
09771
09772 typedef pack<
09773 type0_,
09774 type1_
09775 > input_size_type;
09776
09777 typedef sub_pack<
09778 input_size_type,
09779 true,
09780 false
09781 > sub_pack_type;
09782
09783 typedef typename sub_pack_type::type size_type;
09784
09785 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
09786 {
09787 sub_pack_type::set(res, org);
09788 }
09789
09790 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
09791 {
09792 sub_pack_type::set(res, org);
09793 }
09794 };
09795
09796
09797 template<
09798 typename type0_,
09799 typename type1_,
09800 typename type2_
09801 >
09802 struct size_transformer<
09803 plane<1>,
09804 pack<
09805 type0_,
09806 type1_,
09807 type2_
09808 > >
09809 {
09810 public:
09811 typedef plane<1> transform_type;
09812
09813 typedef pack<
09814 type0_,
09815 type1_,
09816 type2_
09817 > input_size_type;
09818
09819 typedef sub_pack<
09820 input_size_type,
09821 true,
09822 false,
09823 true
09824 > sub_pack_type;
09825
09826 typedef typename sub_pack_type::type size_type;
09827
09828 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
09829 {
09830 sub_pack_type::set(res, org);
09831 }
09832
09833 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
09834 {
09835 sub_pack_type::set(res, org);
09836 }
09837 };
09838
09839
09840 template<
09841 typename type0_,
09842 typename type1_,
09843 typename type2_
09844 >
09845 struct size_transformer<
09846 plane<2>,
09847 pack<
09848 type0_,
09849 type1_,
09850 type2_
09851 > >
09852 {
09853 public:
09854 typedef plane<2> transform_type;
09855
09856 typedef pack<
09857 type0_,
09858 type1_,
09859 type2_
09860 > input_size_type;
09861
09862 typedef sub_pack<
09863 input_size_type,
09864 true,
09865 true,
09866 false
09867 > sub_pack_type;
09868
09869 typedef typename sub_pack_type::type size_type;
09870
09871 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
09872 {
09873 sub_pack_type::set(res, org);
09874 }
09875
09876 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
09877 {
09878 sub_pack_type::set(res, org);
09879 }
09880 };
09881
09882
09883
09884
09885
09886
09887
09888 template<
09889 typename base_iter_type_,
09890 typename type0_,
09891 typename input_size_type_>
09892 struct iterator_transformer<
09893 plane<0>,
09894 pack<
09895 base_iter_type_,
09896 type0_
09897 >,
09898 input_size_type_>
09899 {
09900 public:
09901 typedef plane<0> transform_type;
09902
09903 typedef pack<
09904 base_iter_type_,
09905 type0_
09906 > input_iterator_type;
09907
09908 typedef input_size_type_ input_size_type;
09909
09910 typedef sub_pack<
09911 input_iterator_type,
09912 true,
09913 false
09914 > sub_pack_type;
09915
09916 typedef typename sub_pack_type::type iterator_type;
09917
09918 static LITE_INLINE void transform(
09919 const input_iterator_type& org,
09920 iterator_type& res)
09921 {
09922 sub_pack_type::set(res, org);
09923 }
09924
09925 static LITE_INLINE void transform(
09926 const transform_type& trans,
09927 const input_iterator_type& org,
09928 iterator_type& res)
09929 {
09930 sub_pack_type::set(res, org.i0+trans.index*org.i1, org.i1);
09931 }
09932
09933 static LITE_INLINE void transform(
09934 const transform_type& trans,
09935 const input_iterator_type& org,
09936 const input_size_type&,
09937 iterator_type& res)
09938 {
09939 sub_pack_type::set(res, org.i0+trans.index*org.i1, org.i1);
09940 }
09941 };
09942
09943
09944 template<
09945 typename base_iter_type_,
09946 typename type0_,
09947 typename type1_,
09948 typename input_size_type_>
09949 struct iterator_transformer<
09950 plane<0>,
09951 pack<
09952 base_iter_type_,
09953 type0_,
09954 type1_
09955 >,
09956 input_size_type_>
09957 {
09958 public:
09959 typedef plane<0> transform_type;
09960
09961 typedef pack<
09962 base_iter_type_,
09963 type0_,
09964 type1_
09965 > input_iterator_type;
09966
09967 typedef input_size_type_ input_size_type;
09968
09969 typedef sub_pack<
09970 input_iterator_type,
09971 true,
09972 false,
09973 true
09974 > sub_pack_type;
09975
09976 typedef typename sub_pack_type::type iterator_type;
09977
09978 static LITE_INLINE void transform(
09979 const input_iterator_type& org,
09980 iterator_type& res)
09981 {
09982 sub_pack_type::set(res, org);
09983 }
09984
09985 static LITE_INLINE void transform(
09986 const transform_type& trans,
09987 const input_iterator_type& org,
09988 iterator_type& res)
09989 {
09990 sub_pack_type::set(res, org.i0+trans.index*org.i1, org.i1, org.i2);
09991 }
09992
09993 static LITE_INLINE void transform(
09994 const transform_type& trans,
09995 const input_iterator_type& org,
09996 const input_size_type&,
09997 iterator_type& res)
09998 {
09999 sub_pack_type::set(res, org.i0+trans.index*org.i1, org.i1, org.i2);
10000 }
10001 };
10002
10003
10004 template<
10005 typename base_iter_type_,
10006 typename type0_,
10007 typename type1_,
10008 typename type2_,
10009 typename input_size_type_>
10010 struct iterator_transformer<
10011 plane<0>,
10012 pack<
10013 base_iter_type_,
10014 type0_,
10015 type1_,
10016 type2_
10017 >,
10018 input_size_type_>
10019 {
10020 public:
10021 typedef plane<0> transform_type;
10022
10023 typedef pack<
10024 base_iter_type_,
10025 type0_,
10026 type1_,
10027 type2_
10028 > input_iterator_type;
10029
10030 typedef input_size_type_ input_size_type;
10031
10032 typedef sub_pack<
10033 input_iterator_type,
10034 true,
10035 false,
10036 true,
10037 true
10038 > sub_pack_type;
10039
10040 typedef typename sub_pack_type::type iterator_type;
10041
10042 static LITE_INLINE void transform(
10043 const input_iterator_type& org,
10044 iterator_type& res)
10045 {
10046 sub_pack_type::set(res, org);
10047 }
10048
10049 static LITE_INLINE void transform(
10050 const transform_type& trans,
10051 const input_iterator_type& org,
10052 iterator_type& res)
10053 {
10054 sub_pack_type::set(res, org.i0+trans.index*org.i1, org.i1, org.i2, org.i3);
10055 }
10056
10057 static LITE_INLINE void transform(
10058 const transform_type& trans,
10059 const input_iterator_type& org,
10060 const input_size_type&,
10061 iterator_type& res)
10062 {
10063 sub_pack_type::set(res, org.i0+trans.index*org.i1, org.i1, org.i2, org.i3);
10064 }
10065 };
10066
10067
10068 template<
10069 typename base_iter_type_,
10070 typename type0_,
10071 typename type1_,
10072 typename input_size_type_>
10073 struct iterator_transformer<
10074 plane<1>,
10075 pack<
10076 base_iter_type_,
10077 type0_,
10078 type1_
10079 >,
10080 input_size_type_>
10081 {
10082 public:
10083 typedef plane<1> transform_type;
10084
10085 typedef pack<
10086 base_iter_type_,
10087 type0_,
10088 type1_
10089 > input_iterator_type;
10090
10091 typedef input_size_type_ input_size_type;
10092
10093 typedef sub_pack<
10094 input_iterator_type,
10095 true,
10096 true,
10097 false
10098 > sub_pack_type;
10099
10100 typedef typename sub_pack_type::type iterator_type;
10101
10102 static LITE_INLINE void transform(
10103 const input_iterator_type& org,
10104 iterator_type& res)
10105 {
10106 sub_pack_type::set(res, org);
10107 }
10108
10109 static LITE_INLINE void transform(
10110 const transform_type& trans,
10111 const input_iterator_type& org,
10112 iterator_type& res)
10113 {
10114 sub_pack_type::set(res, org.i0+trans.index*org.i2, org.i1, org.i2);
10115 }
10116
10117 static LITE_INLINE void transform(
10118 const transform_type& trans,
10119 const input_iterator_type& org,
10120 const input_size_type&,
10121 iterator_type& res)
10122 {
10123 sub_pack_type::set(res, org.i0+trans.index*org.i2, org.i1, org.i2);
10124 }
10125 };
10126
10127
10128 template<
10129 typename base_iter_type_,
10130 typename type0_,
10131 typename type1_,
10132 typename type2_,
10133 typename input_size_type_>
10134 struct iterator_transformer<
10135 plane<1>,
10136 pack<
10137 base_iter_type_,
10138 type0_,
10139 type1_,
10140 type2_
10141 >,
10142 input_size_type_>
10143 {
10144 public:
10145 typedef plane<1> transform_type;
10146
10147 typedef pack<
10148 base_iter_type_,
10149 type0_,
10150 type1_,
10151 type2_
10152 > input_iterator_type;
10153
10154 typedef input_size_type_ input_size_type;
10155
10156 typedef sub_pack<
10157 input_iterator_type,
10158 true,
10159 true,
10160 false,
10161 true
10162 > sub_pack_type;
10163
10164 typedef typename sub_pack_type::type iterator_type;
10165
10166 static LITE_INLINE void transform(
10167 const input_iterator_type& org,
10168 iterator_type& res)
10169 {
10170 sub_pack_type::set(res, org);
10171 }
10172
10173 static LITE_INLINE void transform(
10174 const transform_type& trans,
10175 const input_iterator_type& org,
10176 iterator_type& res)
10177 {
10178 sub_pack_type::set(res, org.i0+trans.index*org.i2, org.i1, org.i2, org.i3);
10179 }
10180
10181 static LITE_INLINE void transform(
10182 const transform_type& trans,
10183 const input_iterator_type& org,
10184 const input_size_type&,
10185 iterator_type& res)
10186 {
10187 sub_pack_type::set(res, org.i0+trans.index*org.i2, org.i1, org.i2, org.i3);
10188 }
10189 };
10190
10191
10192 template<
10193 typename base_iter_type_,
10194 typename type0_,
10195 typename type1_,
10196 typename type2_,
10197 typename input_size_type_>
10198 struct iterator_transformer<
10199 plane<2>,
10200 pack<
10201 base_iter_type_,
10202 type0_,
10203 type1_,
10204 type2_
10205 >,
10206 input_size_type_>
10207 {
10208 public:
10209 typedef plane<2> transform_type;
10210
10211 typedef pack<
10212 base_iter_type_,
10213 type0_,
10214 type1_,
10215 type2_
10216 > input_iterator_type;
10217
10218 typedef input_size_type_ input_size_type;
10219
10220 typedef sub_pack<
10221 input_iterator_type,
10222 true,
10223 true,
10224 true,
10225 false
10226 > sub_pack_type;
10227
10228 typedef typename sub_pack_type::type iterator_type;
10229
10230 static LITE_INLINE void transform(
10231 const input_iterator_type& org,
10232 iterator_type& res)
10233 {
10234 sub_pack_type::set(res, org);
10235 }
10236
10237 static LITE_INLINE void transform(
10238 const transform_type& trans,
10239 const input_iterator_type& org,
10240 iterator_type& res)
10241 {
10242 sub_pack_type::set(res, org.i0+trans.index*org.i3, org.i1, org.i2, org.i3);
10243 }
10244
10245 static LITE_INLINE void transform(
10246 const transform_type& trans,
10247 const input_iterator_type& org,
10248 const input_size_type&,
10249 iterator_type& res)
10250 {
10251 sub_pack_type::set(res, org.i0+trans.index*org.i3, org.i1, org.i2, org.i3);
10252 }
10253 };
10254
10255
10256
10257
10258
10259
10260
10285 class diagonal
10286 {
10287 public:
10288 LITE_INLINE diagonal() {}
10289
10290 LITE_INLINE diagonal(const diagonal&) {}
10291
10292 LITE_INLINE diagonal& operator=(const diagonal&) { return *this; }
10293 };
10294
10295
10296
10297
10298
10299 template<>
10300 struct size_transformer<diagonal, pack<> >
10301 {
10302 public:
10303 typedef diagonal transform_type;
10304 typedef pack<> input_size_type;
10305 typedef pack<> size_type;
10306
10307 static LITE_INLINE void transform(const input_size_type&, size_type&)
10308 {}
10309
10310 static LITE_INLINE void transform(const transform_type&, const input_size_type&, size_type&)
10311 {}
10312 };
10313
10314
10315
10316 template<
10317 typename type0_
10318 >
10319 struct size_transformer<
10320 diagonal,
10321 pack<
10322 type0_
10323 > >
10324 {
10325 private:
10326 static const int n0_ =
10327 detail::type_if<detail::same_type<type0_, int>::result, constant<int, 0>, type0_>::type::value;
10328
10329 static const int min_upto_0_ = n0_;
10330
10331 static const int min_dim_size_ = min_upto_0_;
10332
10333 static const bool has_var_size_ =
10334 detail::same_type<type0_, int>::result
10335 ;
10336
10337 public:
10338 typedef diagonal transform_type;
10339
10340 typedef pack<
10341 type0_
10342 > input_size_type;
10343
10344
10345 typedef pack<
10346 typename detail::type_if<has_var_size_, int, constant<int, min_dim_size_> >::type
10347 > size_type;
10348
10349 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
10350 {
10351 const int min_upto_0 = res.i0;
10352
10353 res.set(min_upto_0);
10354 LITE_ARRAY_USE(org);
10355 }
10356
10357 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
10358 {
10359 const int min_upto_0 = res.i0;
10360
10361 res.set(min_upto_0);
10362 LITE_ARRAY_USE(org);
10363 }
10364 };
10365
10366
10367 template<
10368 typename type0_,
10369 typename type1_
10370 >
10371 struct size_transformer<
10372 diagonal,
10373 pack<
10374 type0_,
10375 type1_
10376 > >
10377 {
10378 private:
10379 static const int n0_ =
10380 detail::type_if<detail::same_type<type0_, int>::result, constant<int, 0>, type0_>::type::value;
10381 static const int n1_ =
10382 detail::type_if<detail::same_type<type1_, int>::result, constant<int, 0>, type1_>::type::value;
10383
10384 static const int min_upto_0_ = n0_;
10385 static const int min_upto_1_ = min_upto_0_ < n1_ ? min_upto_0_ : n1_;
10386
10387 static const int min_dim_size_ = min_upto_1_;
10388
10389 static const bool has_var_size_ =
10390 detail::same_type<type0_, int>::result||
10391 detail::same_type<type1_, int>::result
10392 ;
10393
10394 public:
10395 typedef diagonal transform_type;
10396
10397 typedef pack<
10398 type0_,
10399 type1_
10400 > input_size_type;
10401
10402
10403 typedef pack<
10404 typename detail::type_if<has_var_size_, int, constant<int, min_dim_size_> >::type
10405 > size_type;
10406
10407 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
10408 {
10409 const int min_upto_0 = res.i0;
10410 const int min_upto_1 = min_upto_0 < res.i1 ? min_upto_0 : res.i1;
10411
10412 res.set(min_upto_1);
10413 LITE_ARRAY_USE(org);
10414 }
10415
10416 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
10417 {
10418 const int min_upto_0 = res.i0;
10419 const int min_upto_1 = min_upto_0 < org.i1 ? min_upto_0 : org.i1;
10420
10421 res.set(min_upto_1);
10422 LITE_ARRAY_USE(org);
10423 }
10424 };
10425
10426
10427 template<
10428 typename type0_,
10429 typename type1_,
10430 typename type2_
10431 >
10432 struct size_transformer<
10433 diagonal,
10434 pack<
10435 type0_,
10436 type1_,
10437 type2_
10438 > >
10439 {
10440 private:
10441 static const int n0_ =
10442 detail::type_if<detail::same_type<type0_, int>::result, constant<int, 0>, type0_>::type::value;
10443 static const int n1_ =
10444 detail::type_if<detail::same_type<type1_, int>::result, constant<int, 0>, type1_>::type::value;
10445 static const int n2_ =
10446 detail::type_if<detail::same_type<type2_, int>::result, constant<int, 0>, type2_>::type::value;
10447
10448 static const int min_upto_0_ = n0_;
10449 static const int min_upto_1_ = min_upto_0_ < n1_ ? min_upto_0_ : n1_;
10450 static const int min_upto_2_ = min_upto_1_ < n2_ ? min_upto_1_ : n2_;
10451
10452 static const int min_dim_size_ = min_upto_2_;
10453
10454 static const bool has_var_size_ =
10455 detail::same_type<type0_, int>::result||
10456 detail::same_type<type1_, int>::result||
10457 detail::same_type<type2_, int>::result
10458 ;
10459
10460 public:
10461 typedef diagonal transform_type;
10462
10463 typedef pack<
10464 type0_,
10465 type1_,
10466 type2_
10467 > input_size_type;
10468
10469
10470 typedef pack<
10471 typename detail::type_if<has_var_size_, int, constant<int, min_dim_size_> >::type
10472 > size_type;
10473
10474 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
10475 {
10476 const int min_upto_0 = res.i0;
10477 const int min_upto_1 = min_upto_0 < res.i1 ? min_upto_0 : res.i1;
10478 const int min_upto_2 = min_upto_1 < res.i2 ? min_upto_1 : res.i2;
10479
10480 res.set(min_upto_2);
10481 LITE_ARRAY_USE(org);
10482 }
10483
10484 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
10485 {
10486 const int min_upto_0 = res.i0;
10487 const int min_upto_1 = min_upto_0 < org.i1 ? min_upto_0 : org.i1;
10488 const int min_upto_2 = min_upto_1 < org.i2 ? min_upto_1 : org.i2;
10489
10490 res.set(min_upto_2);
10491 LITE_ARRAY_USE(org);
10492 }
10493 };
10494
10495
10496
10497
10498
10499
10500
10501
10502 template<typename base_iter_type_, typename input_size_type_>
10503 struct iterator_transformer<diagonal, pack<base_iter_type_>, input_size_type_>
10504 {
10505 public:
10506 typedef pack<base_iter_type_> input_iterator_type;
10507
10508 typedef input_size_type_ input_size_type;
10509
10510 typedef pack<base_iter_type_> iterator_type;
10511
10512 static LITE_INLINE void transform(
10513 const input_iterator_type& org,
10514 iterator_type& res)
10515 {
10516 res.i0 = org.i0;
10517 }
10518
10519 static LITE_INLINE void transform(
10520 const diagonal&,
10521 const input_iterator_type& org,
10522 iterator_type& res)
10523 {
10524 res.i0 = org.i0;
10525 }
10526
10527 static LITE_INLINE void transform(
10528 const diagonal&,
10529 const input_iterator_type& org,
10530 const input_size_type&,
10531 iterator_type& res)
10532 {
10533 res.i0 = org.i0;
10534 }
10535 };
10536
10537
10538
10539 template<
10540 typename base_iter_type_,
10541 typename type0_,
10542 typename input_size_type_>
10543 struct iterator_transformer<
10544 diagonal,
10545 pack<
10546 base_iter_type_,
10547 type0_
10548 >,
10549 input_size_type_>
10550 {
10551 private:
10552 static const int n0_ =
10553 detail::type_if<detail::same_type<type0_, int>::result, constant<int, 0>, type0_>::type::value;
10554
10555 static const int stride_ = n0_;
10556
10557 static const bool has_var_stride_ =
10558 detail::same_type<type0_, int>::result
10559 ;
10560
10561 public:
10562 typedef diagonal transform_type;
10563 typedef pack<
10564 base_iter_type_,
10565 type0_
10566 > input_iterator_type;
10567
10568 typedef input_size_type_ input_size_type;
10569
10570 typedef pack<
10571 base_iter_type_,
10572 typename detail::type_if<has_var_stride_, int, constant<int, stride_> >::type>
10573 iterator_type;
10574
10575 static LITE_INLINE void transform(
10576 const input_iterator_type& org,
10577 iterator_type& res)
10578 {
10579 res.set(org.i0, org.i1);
10580 }
10581
10582 static LITE_INLINE void transform(
10583 const transform_type&,
10584 const input_iterator_type& org,
10585 iterator_type& res)
10586 {
10587 res.set(org.i0, org.i1);
10588 }
10589
10590 static LITE_INLINE void transform(
10591 const transform_type&,
10592 const input_iterator_type& org,
10593 const input_size_type&,
10594 iterator_type& res)
10595 {
10596 res.set(org.i0, org.i1);
10597 }
10598 };
10599
10600
10601 template<
10602 typename base_iter_type_,
10603 typename type0_,
10604 typename type1_,
10605 typename input_size_type_>
10606 struct iterator_transformer<
10607 diagonal,
10608 pack<
10609 base_iter_type_,
10610 type0_,
10611 type1_
10612 >,
10613 input_size_type_>
10614 {
10615 private:
10616 static const int n0_ =
10617 detail::type_if<detail::same_type<type0_, int>::result, constant<int, 0>, type0_>::type::value;
10618 static const int n1_ =
10619 detail::type_if<detail::same_type<type1_, int>::result, constant<int, 0>, type1_>::type::value;
10620
10621 static const int stride_ = n0_ + n1_;
10622
10623 static const bool has_var_stride_ =
10624 detail::same_type<type0_, int>::result||
10625 detail::same_type<type1_, int>::result
10626 ;
10627
10628 public:
10629 typedef diagonal transform_type;
10630 typedef pack<
10631 base_iter_type_,
10632 type0_,
10633 type1_
10634 > input_iterator_type;
10635
10636 typedef input_size_type_ input_size_type;
10637
10638 typedef pack<
10639 base_iter_type_,
10640 typename detail::type_if<has_var_stride_, int, constant<int, stride_> >::type>
10641 iterator_type;
10642
10643 static LITE_INLINE void transform(
10644 const input_iterator_type& org,
10645 iterator_type& res)
10646 {
10647 res.set(org.i0, org.i1org.i2);
10648 }
10649
10650 static LITE_INLINE void transform(
10651 const transform_type&,
10652 const input_iterator_type& org,
10653 iterator_type& res)
10654 {
10655 res.set(org.i0, org.i1org.i2);
10656 }
10657
10658 static LITE_INLINE void transform(
10659 const transform_type&,
10660 const input_iterator_type& org,
10661 const input_size_type&,
10662 iterator_type& res)
10663 {
10664 res.set(org.i0, org.i1 + org.i2);
10665 }
10666 };
10667
10668
10669 template<
10670 typename base_iter_type_,
10671 typename type0_,
10672 typename type1_,
10673 typename type2_,
10674 typename input_size_type_>
10675 struct iterator_transformer<
10676 diagonal,
10677 pack<
10678 base_iter_type_,
10679 type0_,
10680 type1_,
10681 type2_
10682 >,
10683 input_size_type_>
10684 {
10685 private:
10686 static const int n0_ =
10687 detail::type_if<detail::same_type<type0_, int>::result, constant<int, 0>, type0_>::type::value;
10688 static const int n1_ =
10689 detail::type_if<detail::same_type<type1_, int>::result, constant<int, 0>, type1_>::type::value;
10690 static const int n2_ =
10691 detail::type_if<detail::same_type<type2_, int>::result, constant<int, 0>, type2_>::type::value;
10692
10693 static const int stride_ = n0_ + n1_ + n2_;
10694
10695 static const bool has_var_stride_ =
10696 detail::same_type<type0_, int>::result||
10697 detail::same_type<type1_, int>::result||
10698 detail::same_type<type2_, int>::result
10699 ;
10700
10701 public:
10702 typedef diagonal transform_type;
10703 typedef pack<
10704 base_iter_type_,
10705 type0_,
10706 type1_,
10707 type2_
10708 > input_iterator_type;
10709
10710 typedef input_size_type_ input_size_type;
10711
10712 typedef pack<
10713 base_iter_type_,
10714 typename detail::type_if<has_var_stride_, int, constant<int, stride_> >::type>
10715 iterator_type;
10716
10717 static LITE_INLINE void transform(
10718 const input_iterator_type& org,
10719 iterator_type& res)
10720 {
10721 res.set(org.i0, org.i1org.i2org.i3);
10722 }
10723
10724 static LITE_INLINE void transform(
10725 const transform_type&,
10726 const input_iterator_type& org,
10727 iterator_type& res)
10728 {
10729 res.set(org.i0, org.i1org.i2org.i3);
10730 }
10731
10732 static LITE_INLINE void transform(
10733 const transform_type&,
10734 const input_iterator_type& org,
10735 const input_size_type&,
10736 iterator_type& res)
10737 {
10738 res.set(org.i0, org.i1 + org.i2 + org.i3);
10739 }
10740 };
10741
10742
10743
10744
10745
10746
10747
10768 class transpose
10769 {
10770 public:
10771 LITE_INLINE transpose() {}
10772
10773 LITE_INLINE transpose(const transpose&) {}
10774
10775 LITE_INLINE transpose& operator=(const transpose&) { return *this; }
10776 };
10777
10778
10779
10780
10781
10782 template<>
10783 struct size_transformer<transpose, pack<> >
10784 {
10785 public:
10786 typedef transpose transform_type;
10787
10788 typedef pack<> input_size_type;
10789
10790 typedef pack<> size_type;
10791
10792 static LITE_INLINE void transform(const input_size_type&, size_type&)
10793 {}
10794
10795 static LITE_INLINE void transform(const transform_type&, const input_size_type&, size_type&)
10796 {}
10797 };
10798
10799
10800
10801 template<
10802 typename type0_
10803 >
10804 struct size_transformer<
10805 transpose,
10806 pack<
10807 type0_
10808 > >
10809 {
10810 public:
10811 typedef transpose transform_type;
10812
10813 typedef pack<
10814 type0_
10815 > input_size_type;
10816
10817 typedef pack<
10818 type0_
10819 > size_type;
10820
10821 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
10822 {
10823 set<0>(res, org.i0);
10824 LITE_ARRAY_USE(org);
10825 }
10826
10827 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
10828 {
10829 set<0>(res, org.i0);
10830 LITE_ARRAY_USE(org);
10831 }
10832 };
10833
10834
10835 template<
10836 typename type0_,
10837 typename type1_
10838 >
10839 struct size_transformer<
10840 transpose,
10841 pack<
10842 type0_,
10843 type1_
10844 > >
10845 {
10846 public:
10847 typedef transpose transform_type;
10848
10849 typedef pack<
10850 type0_,
10851 type1_
10852 > input_size_type;
10853
10854 typedef pack<
10855 type1_,
10856 type0_
10857 > size_type;
10858
10859 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
10860 {
10861 set<0>(res, org.i1);
10862 set<1>(res, org.i0);
10863 LITE_ARRAY_USE(org);
10864 }
10865
10866 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
10867 {
10868 set<0>(res, org.i1);
10869 set<1>(res, org.i0);
10870 LITE_ARRAY_USE(org);
10871 }
10872 };
10873
10874
10875 template<
10876 typename type0_,
10877 typename type1_,
10878 typename type2_
10879 >
10880 struct size_transformer<
10881 transpose,
10882 pack<
10883 type0_,
10884 type1_,
10885 type2_
10886 > >
10887 {
10888 public:
10889 typedef transpose transform_type;
10890
10891 typedef pack<
10892 type0_,
10893 type1_,
10894 type2_
10895 > input_size_type;
10896
10897 typedef pack<
10898 type2_,
10899 type1_,
10900 type0_
10901 > size_type;
10902
10903 static LITE_INLINE void transform(const input_size_type& org, size_type& res)
10904 {
10905 set<0>(res, org.i2);
10906 set<1>(res, org.i1);
10907 set<2>(res, org.i0);
10908 LITE_ARRAY_USE(org);
10909 }
10910
10911 static LITE_INLINE void transform(const transform_type&, const input_size_type& org, size_type& res)
10912 {
10913 set<0>(res, org.i2);
10914 set<1>(res, org.i1);
10915 set<2>(res, org.i0);
10916 LITE_ARRAY_USE(org);
10917 }
10918 };
10919
10920
10921
10922
10923
10924
10925
10926 template<typename base_iter_type_, typename input_size_type_>
10927 struct iterator_transformer<transpose, pack<base_iter_type_>, input_size_type_>
10928 {
10929 public:
10930 typedef transpose transform_type;
10931 typedef pack<base_iter_type_> input_iterator_type;
10932 typedef input_size_type_ input_size_type;
10933 typedef pack<base_iter_type_> iterator_type;
10934
10935 static LITE_INLINE void transform(
10936 const input_iterator_type& org,
10937 iterator_type& res)
10938 {
10939 res.i0 = org.i0;
10940 }
10941
10942 static LITE_INLINE void transform(
10943 const transform_type&,
10944 const input_iterator_type& org,
10945 iterator_type& res)
10946 {
10947 res.i0 = org.i0;
10948 }
10949
10950 static LITE_INLINE void transform(
10951 const transform_type&,
10952 const input_iterator_type& org,
10953 const input_size_type&,
10954 iterator_type& res)
10955 {
10956 res.i0 = org.i0;
10957 }
10958 };
10959
10960
10961
10962
10963 template<
10964 typename base_iter_type_,
10965 typename type0_,
10966 typename input_size_type_>
10967 struct iterator_transformer<
10968 transpose,
10969 pack<
10970 base_iter_type_,
10971 type0_
10972 >,
10973 input_size_type_>
10974 {
10975 public:
10976 typedef transpose transform_type;
10977 typedef pack<
10978 base_iter_type_,
10979 type0_
10980 > input_iterator_type;
10981
10982 typedef input_size_type_ input_size_type;
10983 typedef pack<
10984 base_iter_type_,
10985 type0_
10986 > iterator_type;
10987
10988 static LITE_INLINE void transform(
10989 const input_iterator_type& org,
10990 iterator_type& res)
10991 {
10992 res.i0 = org.i0;
10993 set<1>(res, org.i1);
10994 }
10995
10996 static LITE_INLINE void transform(
10997 const transform_type&,
10998 const input_iterator_type& org,
10999 iterator_type& res)
11000 {
11001 res.i0 = org.i0;
11002 set<1>(res, org.i1);
11003 }
11004
11005 static LITE_INLINE void transform(
11006 const transform_type&,
11007 const input_iterator_type& org,
11008 const input_size_type&,
11009 iterator_type& res)
11010 {
11011 res.i0 = org.i0;
11012 set<1>(res, org.i1);
11013 }
11014 };
11015
11016
11017
11018 template<
11019 typename base_iter_type_,
11020 typename type0_,
11021 typename type1_,
11022 typename input_size_type_>
11023 struct iterator_transformer<
11024 transpose,
11025 pack<
11026 base_iter_type_,
11027 type0_,
11028 type1_
11029 >,
11030 input_size_type_>
11031 {
11032 public:
11033 typedef transpose transform_type;
11034 typedef pack<
11035 base_iter_type_,
11036 type0_,
11037 type1_
11038 > input_iterator_type;
11039
11040 typedef input_size_type_ input_size_type;
11041 typedef pack<
11042 base_iter_type_,
11043 type1_,
11044 type0_
11045 > iterator_type;
11046
11047 static LITE_INLINE void transform(
11048 const input_iterator_type& org,
11049 iterator_type& res)
11050 {
11051 res.i0 = org.i0;
11052 set<1>(res, org.i2);
11053 set<2>(res, org.i1);
11054 }
11055
11056 static LITE_INLINE void transform(
11057 const transform_type&,
11058 const input_iterator_type& org,
11059 iterator_type& res)
11060 {
11061 res.i0 = org.i0;
11062 set<1>(res, org.i2);
11063 set<2>(res, org.i1);
11064 }
11065
11066 static LITE_INLINE void transform(
11067 const transform_type&,
11068 const input_iterator_type& org,
11069 const input_size_type&,
11070 iterator_type& res)
11071 {
11072 res.i0 = org.i0;
11073 set<1>(res, org.i2);
11074 set<2>(res, org.i1);
11075 }
11076 };
11077
11078
11079
11080 template<
11081 typename base_iter_type_,
11082 typename type0_,
11083 typename type1_,
11084 typename type2_,
11085 typename input_size_type_>
11086 struct iterator_transformer<
11087 transpose,
11088 pack<
11089 base_iter_type_,
11090 type0_,
11091 type1_,
11092 type2_
11093 >,
11094 input_size_type_>
11095 {
11096 public:
11097 typedef transpose transform_type;
11098 typedef pack<
11099 base_iter_type_,
11100 type0_,
11101 type1_,
11102 type2_
11103 > input_iterator_type;
11104
11105 typedef input_size_type_ input_size_type;
11106 typedef pack<
11107 base_iter_type_,
11108 type2_,
11109 type1_,
11110 type0_
11111 > iterator_type;
11112
11113 static LITE_INLINE void transform(
11114 const input_iterator_type& org,
11115 iterator_type& res)
11116 {
11117 res.i0 = org.i0;
11118 set<1>(res, org.i3);
11119 set<2>(res, org.i2);
11120 set<3>(res, org.i1);
11121 }
11122
11123 static LITE_INLINE void transform(
11124 const transform_type&,
11125 const input_iterator_type& org,
11126 iterator_type& res)
11127 {
11128 res.i0 = org.i0;
11129 set<1>(res, org.i3);
11130 set<2>(res, org.i2);
11131 set<3>(res, org.i1);
11132 }
11133
11134 static LITE_INLINE void transform(
11135 const transform_type&,
11136 const input_iterator_type& org,
11137 const input_size_type&,
11138 iterator_type& res)
11139 {
11140 res.i0 = org.i0;
11141 set<1>(res, org.i3);
11142 set<2>(res, org.i2);
11143 set<3>(res, org.i1);
11144 }
11145 };
11146
11147
11148
11149
11150
11151
11152
11153 #ifdef DOCUMENTATION_ONLY
11154
11253 template<int n0_ ..., int nN_>
11254 class block
11255 {
11256 public:
11258 typedef pack<...> size_type;
11259
11260 block() {}
11261
11262 block(const block& other);
11263
11271 block(int n0, ..., int nN);
11272
11280 block(const size_type& block_size, int i0 ..., int iN);
11281
11282 block& operator=(const block& other);
11283
11292 block operator()(int i0 ..., int iN) const;
11293
11295 size_type block_size;
11296
11298 int iX;
11299 };
11300
11301 #else // DOCUMENTATION_ONLY
11302
11303
11304 template<
11305 >
11306 class block<
11307 >
11308 {
11309 public:
11310
11311 typedef pack<
11312 > size_type;
11313
11314 LITE_INLINE block()
11315 : block_size()
11316 {}
11317
11318 LITE_INLINE block(const block& other)
11319 : block_size(other.block_size)
11320 {}
11321
11322
11323 LITE_INLINE block(const size_type& bs )
11324 : block_size(bs)
11325 {}
11326
11327 LITE_INLINE block& operator=(const block& other)
11328 {
11329 block_size = other.block_size;
11330 return *this;
11331 }
11332
11333 LITE_INLINE block
11334 operator()() const
11335 {
11336 return block(block_size );
11337 }
11338
11339 size_type block_size;
11340 };
11341
11342
11343
11344 template<
11345 int n0_
11346 >
11347 class block<
11348 n0_
11349 >
11350 {
11351 public:
11352
11353 typedef pack<
11354 typename detail::type_if<n0_==1, int, constant<int, n0_> >::type
11355 > size_type;
11356
11357 LITE_INLINE block()
11358 : block_size(),
11359 i0()
11360 {}
11361
11362 LITE_INLINE block(const block& other)
11363 : block_size(other.block_size),
11364 i0(other.i0)
11365 {}
11366
11367 LITE_INLINE block(int n0)
11368 : block_size(n0),
11369 i0()
11370 {}
11371
11372 LITE_INLINE block(const size_type& bs, int i0)
11373 : block_size(bs),
11374 i0(i0)
11375 {}
11376
11377 LITE_INLINE block& operator=(const block& other)
11378 {
11379 block_size = other.block_size;
11380 i0 = other.i0;
11381 return *this;
11382 }
11383
11384 LITE_INLINE block
11385 operator()(int i0) const
11386 {
11387 return block(block_size, i0);
11388 }
11389
11390 size_type block_size;
11391 int i0;
11392 };
11393
11394
11395
11396 template<
11397 int n0_,
11398 int n1_
11399 >
11400 class block<
11401 n0_,
11402 n1_
11403 >
11404 {
11405 public:
11406
11407 typedef pack<
11408 typename detail::type_if<n0_==1, int, constant<int, n0_> >::type,
11409 typename detail::type_if<n1_==1, int, constant<int, n1_> >::type
11410 > size_type;
11411
11412 LITE_INLINE block()
11413 : block_size(),
11414 i0(),
11415 i1()
11416 {}
11417
11418 LITE_INLINE block(const block& other)
11419 : block_size(other.block_size),
11420 i0(other.i0),
11421 i1(other.i1)
11422 {}
11423
11424 LITE_INLINE block(int n0, int n1)
11425 : block_size(n0, n1),
11426 i0(),
11427 i1()
11428 {}
11429
11430 LITE_INLINE block(const size_type& bs, int i0, int i1)
11431 : block_size(bs),
11432 i0(i0),
11433 i1(i1)
11434 {}
11435
11436 LITE_INLINE block& operator=(const block& other)
11437 {
11438 block_size = other.block_size;
11439 i0 = other.i0;
11440 i1 = other.i1;
11441 return *this;
11442 }
11443
11444 LITE_INLINE block
11445 operator()(int i0, int i1) const
11446 {
11447 return block(block_size, i0, i1);
11448 }
11449
11450 size_type block_size;
11451 int i0;
11452 int i1;
11453 };
11454
11455
11456
11457 template<
11458 int n0_,
11459 int n1_,
11460 int n2_
11461 >
11462 class block
11463 {
11464 public:
11465
11466 typedef pack<
11467 typename detail::type_if<n0_==1, int, constant<int, n0_> >::type,
11468 typename detail::type_if<n1_==1, int, constant<int, n1_> >::type,
11469 typename detail::type_if<n2_==1, int, constant<int, n2_> >::type
11470 > size_type;
11471
11472 LITE_INLINE block()
11473 : block_size(),
11474 i0(),
11475 i1(),
11476 i2()
11477 {}
11478
11479 LITE_INLINE block(const block& other)
11480 : block_size(other.block_size),
11481 i0(other.i0),
11482 i1(other.i1),
11483 i2(other.i2)
11484 {}
11485
11486 LITE_INLINE block(int n0, int n1, int n2)
11487 : block_size(n0, n1, n2),
11488 i0(),
11489 i1(),
11490 i2()
11491 {}
11492
11493 LITE_INLINE block(const size_type& bs, int i0, int i1, int i2)
11494 : block_size(bs),
11495 i0(i0),
11496 i1(i1),
11497 i2(i2)
11498 {}
11499
11500 LITE_INLINE block& operator=(const block& other)
11501 {
11502 block_size = other.block_size;
11503 i0 = other.i0;
11504 i1 = other.i1;
11505 i2 = other.i2;
11506 return *this;
11507 }
11508
11509 LITE_INLINE block
11510 operator()(int i0, int i1, int i2) const
11511 {
11512 return block(block_size, i0, i1, i2);
11513 }
11514
11515 size_type block_size;
11516 int i0;
11517 int i1;
11518 int i2;
11519 };
11520
11521
11522
11523 #endif // DOCUMENTATION_ONLY
11524
11525
11526
11527
11528
11529
11530 template<
11531 >
11532 struct size_transformer<
11533 block<
11534 >,
11535 pack<
11536 > >
11537 {
11538 typedef block<
11539 > transfrom_type;
11540
11541 typedef pack<
11542 > input_size_type;
11543
11544 typedef pack<
11545 > ex_size_type;
11546
11547 typedef sub_pack<
11548 ex_size_type
11549 > sub_pack_type;
11550
11551
11552 typedef sub_pack_type::type size_type;
11553
11554 static LITE_INLINE void transform(const transfrom_type&, const input_size_type&, size_type&)
11555 {}
11556
11557 private:
11558 typedef detail::compile_time_assert<transfrom_type::size_type::n == input_size_type::n>
11559 ::verified verified;
11560 };
11561
11562
11563
11564 template<
11565 int n0_,
11566 typename type0_
11567 >
11568 struct size_transformer<
11569 block<
11570 n0_
11571 >,
11572 pack<
11573 type0_
11574 > >
11575 {
11576 typedef block<
11577 n0_
11578 > transfrom_type;
11579
11580 typedef pack<
11581 type0_
11582 > input_size_type;
11583
11584 typedef pack<
11585 typename detail::type_if<
11586 n0_ == -1,
11587 type0_,
11588 typename detail::type_if<n0_ == 1, int, constant<int, n0_> >::type
11589 >::type
11590 > ex_size_type;
11591
11592 typedef sub_pack<
11593 ex_size_type,
11594 n0_!=0
11595 > sub_pack_type;
11596
11597
11598 typedef typename sub_pack_type::type size_type;
11599
11600 static LITE_INLINE void
11601 transform(const transfrom_type& trans, const input_size_type& org, size_type& res)
11602 {
11603 sub_pack_type::set(
11604 res,
11605 n0_==-1 ? org.i0 : trans.block_size.i0
11606 );
11607 LITE_ARRAY_USE(trans);
11608 LITE_ARRAY_USE(org);
11609 }
11610
11611 private:
11612 typedef typename detail::compile_time_assert<transfrom_type::size_type::n == input_size_type::n>
11613 ::verified verified;
11614 };
11615
11616
11617
11618 template<
11619 int n0_,
11620 int n1_,
11621 typename type0_,
11622 typename type1_
11623 >
11624 struct size_transformer<
11625 block<
11626 n0_,
11627 n1_
11628 >,
11629 pack<
11630 type0_,
11631 type1_
11632 > >
11633 {
11634 typedef block<
11635 n0_,
11636 n1_
11637 > transfrom_type;
11638
11639 typedef pack<
11640 type0_,
11641 type1_
11642 > input_size_type;
11643
11644 typedef pack<
11645 typename detail::type_if<
11646 n0_ == -1,
11647 type0_,
11648 typename detail::type_if<n0_ == 1, int, constant<int, n0_> >::type
11649 >::type,
11650 typename detail::type_if<
11651 n1_ == -1,
11652 type1_,
11653 typename detail::type_if<n1_ == 1, int, constant<int, n1_> >::type
11654 >::type
11655 > ex_size_type;
11656
11657 typedef sub_pack<
11658 ex_size_type,
11659 n0_!=0,
11660 n1_!=0
11661 > sub_pack_type;
11662
11663
11664 typedef typename sub_pack_type::type size_type;
11665
11666 static LITE_INLINE void
11667 transform(const transfrom_type& trans, const input_size_type& org, size_type& res)
11668 {
11669 sub_pack_type::set(
11670 res,
11671 n0_==-1 ? org.i0 : trans.block_size.i0,
11672 n1_==-1 ? org.i1 : trans.block_size.i1
11673 );
11674 LITE_ARRAY_USE(trans);
11675 LITE_ARRAY_USE(org);
11676 }
11677
11678 private:
11679 typedef typename detail::compile_time_assert<transfrom_type::size_type::n == input_size_type::n>
11680 ::verified verified;
11681 };
11682
11683
11684
11685 template<
11686 int n0_,
11687 int n1_,
11688 int n2_,
11689 typename type0_,
11690 typename type1_,
11691 typename type2_
11692 >
11693 struct size_transformer<
11694 block<
11695 n0_,
11696 n1_,
11697 n2_
11698 >,
11699 pack<
11700 type0_,
11701 type1_,
11702 type2_
11703 > >
11704 {
11705 typedef block<
11706 n0_,
11707 n1_,
11708 n2_
11709 > transfrom_type;
11710
11711 typedef pack<
11712 type0_,
11713 type1_,
11714 type2_
11715 > input_size_type;
11716
11717 typedef pack<
11718 typename detail::type_if<
11719 n0_ == -1,
11720 type0_,
11721 typename detail::type_if<n0_ == 1, int, constant<int, n0_> >::type
11722 >::type,
11723 typename detail::type_if<
11724 n1_ == -1,
11725 type1_,
11726 typename detail::type_if<n1_ == 1, int, constant<int, n1_> >::type
11727 >::type,
11728 typename detail::type_if<
11729 n2_ == -1,
11730 type2_,
11731 typename detail::type_if<n2_ == 1, int, constant<int, n2_> >::type
11732 >::type
11733 > ex_size_type;
11734
11735 typedef sub_pack<
11736 ex_size_type,
11737 n0_!=0,
11738 n1_!=0,
11739 n2_!=0
11740 > sub_pack_type;
11741
11742
11743 typedef typename sub_pack_type::type size_type;
11744
11745 static LITE_INLINE void
11746 transform(const transfrom_type& trans, const input_size_type& org, size_type& res)
11747 {
11748 sub_pack_type::set(
11749 res,
11750 n0_==-1 ? org.i0 : trans.block_size.i0,
11751 n1_==-1 ? org.i1 : trans.block_size.i1,
11752 n2_==-1 ? org.i2 : trans.block_size.i2
11753 );
11754 LITE_ARRAY_USE(trans);
11755 LITE_ARRAY_USE(org);
11756 }
11757
11758 private:
11759 typedef typename detail::compile_time_assert<transfrom_type::size_type::n == input_size_type::n>
11760 ::verified verified;
11761 };
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771 template<
11772 typename base_iterator_type_,
11773 typename input_size_type_
11774 >
11775 struct iterator_transformer<
11776 block<
11777 >,
11778 pack<
11779 base_iterator_type_
11780 >,
11781 input_size_type_
11782 >
11783 {
11784 typedef block<
11785 > transfrom_type;
11786
11787 typedef pack<
11788 base_iterator_type_
11789 > input_iterator_type;
11790
11791 typedef sub_pack<
11792 input_iterator_type,
11793 true
11794 > sub_pack_type;
11795
11796 typedef typename sub_pack_type::type iterator_type;
11797
11798 static LITE_INLINE void
11799 transform(
11800 const transfrom_type& trans,
11801 const input_iterator_type& org,
11802 iterator_type& res)
11803 {
11804 sub_pack_type::set(res, org.i0
11805
11806 );
11807
11808 LITE_ARRAY_USE(trans);
11809 }
11810
11811 static LITE_INLINE void
11812 transform(
11813 const transfrom_type& trans,
11814 const input_iterator_type& org,
11815 const input_size_type_&,
11816 iterator_type& res)
11817 {
11818 sub_pack_type::set(res, org.i0
11819
11820 );
11821
11822 LITE_ARRAY_USE(trans);
11823 }
11824
11825 private:
11826 typedef typename detail::compile_time_assert<transfrom_type::size_type::n == input_size_type_::n>
11827 ::verified verified;
11828 };
11829
11830
11831
11832 template<
11833 int n0_,
11834 typename base_iterator_type_,
11835 typename type0_,
11836 typename input_size_type_
11837 >
11838 struct iterator_transformer<
11839 block<
11840 n0_
11841 >,
11842 pack<
11843 base_iterator_type_,
11844 type0_
11845 >,
11846 input_size_type_
11847 >
11848 {
11849 typedef block<
11850 n0_
11851 > transfrom_type;
11852
11853 typedef pack<
11854 base_iterator_type_,
11855 type0_
11856 > input_iterator_type;
11857
11858 typedef sub_pack<
11859 input_iterator_type,
11860 true,
11861 n0_!=0
11862 > sub_pack_type;
11863
11864 typedef typename sub_pack_type::type iterator_type;
11865
11866 static LITE_INLINE void
11867 transform(
11868 const transfrom_type& trans,
11869 const input_iterator_type& org,
11870 iterator_type& res)
11871 {
11872 sub_pack_type::set(res, org.i0
11873 +(n0_ != -1 ? trans.i0*org.i1 : 0)
11874 ,
11875 org.i1
11876 );
11877
11878 }
11879
11880 static LITE_INLINE void
11881 transform(
11882 const transfrom_type& trans,
11883 const input_iterator_type& org,
11884 const input_size_type_&,
11885 iterator_type& res)
11886 {
11887 sub_pack_type::set(res, org.i0
11888 +(n0_ != -1 ? trans.i0*org.i1 : 0)
11889 ,
11890 org.i1
11891 );
11892
11893 }
11894
11895 private:
11896 typedef typename detail::compile_time_assert<transfrom_type::size_type::n == input_size_type_::n>
11897 ::verified verified;
11898 };
11899
11900
11901
11902 template<
11903 int n0_,
11904 int n1_,
11905 typename base_iterator_type_,
11906 typename type0_,
11907 typename type1_,
11908 typename input_size_type_
11909 >
11910 struct iterator_transformer<
11911 block<
11912 n0_,
11913 n1_
11914 >,
11915 pack<
11916 base_iterator_type_,
11917 type0_,
11918 type1_
11919 >,
11920 input_size_type_
11921 >
11922 {
11923 typedef block<
11924 n0_,
11925 n1_
11926 > transfrom_type;
11927
11928 typedef pack<
11929 base_iterator_type_,
11930 type0_,
11931 type1_
11932 > input_iterator_type;
11933
11934 typedef sub_pack<
11935 input_iterator_type,
11936 true,
11937 n0_!=0,
11938 n1_!=0
11939 > sub_pack_type;
11940
11941 typedef typename sub_pack_type::type iterator_type;
11942
11943 static LITE_INLINE void
11944 transform(
11945 const transfrom_type& trans,
11946 const input_iterator_type& org,
11947 iterator_type& res)
11948 {
11949 sub_pack_type::set(res, org.i0
11950 +(n0_ != -1 ? trans.i0*org.i1 : 0)
11951 +(n1_ != -1 ? trans.i1*org.i2 : 0)
11952 ,
11953 org.i1,
11954 org.i2
11955 );
11956
11957 }
11958
11959 static LITE_INLINE void
11960 transform(
11961 const transfrom_type& trans,
11962 const input_iterator_type& org,
11963 const input_size_type_&,
11964 iterator_type& res)
11965 {
11966 sub_pack_type::set(res, org.i0
11967 +(n0_ != -1 ? trans.i0*org.i1 : 0)
11968 +(n1_ != -1 ? trans.i1*org.i2 : 0)
11969 ,
11970 org.i1,
11971 org.i2
11972 );
11973
11974 }
11975
11976 private:
11977 typedef typename detail::compile_time_assert<transfrom_type::size_type::n == input_size_type_::n>
11978 ::verified verified;
11979 };
11980
11981
11982
11983 template<
11984 int n0_,
11985 int n1_,
11986 int n2_,
11987 typename base_iterator_type_,
11988 typename type0_,
11989 typename type1_,
11990 typename type2_,
11991 typename input_size_type_
11992 >
11993 struct iterator_transformer<
11994 block<
11995 n0_,
11996 n1_,
11997 n2_
11998 >,
11999 pack<
12000 base_iterator_type_,
12001 type0_,
12002 type1_,
12003 type2_
12004 >,
12005 input_size_type_
12006 >
12007 {
12008 typedef block<
12009 n0_,
12010 n1_,
12011 n2_
12012 > transfrom_type;
12013
12014 typedef pack<
12015 base_iterator_type_,
12016 type0_,
12017 type1_,
12018 type2_
12019 > input_iterator_type;
12020
12021 typedef sub_pack<
12022 input_iterator_type,
12023 true,
12024 n0_!=0,
12025 n1_!=0,
12026 n2_!=0
12027 > sub_pack_type;
12028
12029 typedef typename sub_pack_type::type iterator_type;
12030
12031 static LITE_INLINE void
12032 transform(
12033 const transfrom_type& trans,
12034 const input_iterator_type& org,
12035 iterator_type& res)
12036 {
12037 sub_pack_type::set(res, org.i0
12038 +(n0_ != -1 ? trans.i0*org.i1 : 0)
12039 +(n1_ != -1 ? trans.i1*org.i2 : 0)
12040 +(n2_ != -1 ? trans.i2*org.i3 : 0)
12041 ,
12042 org.i1,
12043 org.i2,
12044 org.i3
12045 );
12046
12047 }
12048
12049 static LITE_INLINE void
12050 transform(
12051 const transfrom_type& trans,
12052 const input_iterator_type& org,
12053 const input_size_type_&,
12054 iterator_type& res)
12055 {
12056 sub_pack_type::set(res, org.i0
12057 +(n0_ != -1 ? trans.i0*org.i1 : 0)
12058 +(n1_ != -1 ? trans.i1*org.i2 : 0)
12059 +(n2_ != -1 ? trans.i2*org.i3 : 0)
12060 ,
12061 org.i1,
12062 org.i2,
12063 org.i3
12064 );
12065
12066 }
12067
12068 private:
12069 typedef typename detail::compile_time_assert<transfrom_type::size_type::n == input_size_type_::n>
12070 ::verified verified;
12071 };
12072
12073
12074
12075
12076
12077
12078
12079 #ifdef DOCUMENTATION_ONLY
12080
12087 template<typename signature_, typename base_iterator_type_>
12088 struct array_signature_traits
12089 {
12091 typedef ??? element_type;
12092
12094 typedef ??? value_type;
12095
12096 typedef signature_ signature;
12097
12102 typedef ??? base_iterator_type;
12103
12109 typedef ??? default_iterator;
12110
12116 typedef ??? default_rev_iterator;
12117
12119 typedef ??? size_type;
12120
12122 static const int dimensions = ???;
12123
12125 static const int volume = ???;
12126
12128 static const bool is_fixed_size = ???;
12129 };
12130
12131 #else // DOCUMENTATION_ONLY
12132
12133 template<typename element_type_, typename base_iterator_type_>
12134 struct array_signature_traits
12135 {
12136 typedef element_type_ element_type;
12137 typedef typename detail::remove<element_type_, volatile const int>::type value_type;
12138 typedef value_type signature;
12139
12140 typedef typename detail::type_if<
12141 detail::same_type<base_iterator_type_, void>::result,
12142 element_type_*,
12143 base_iterator_type_
12144 >::type base_iterator_type;
12145
12146 typedef pack<base_iterator_type> default_iterator;
12147 typedef pack<base_iterator_type> default_rev_iterator;
12148 typedef pack<> size_type;
12149
12150 static const int dimensions = 0;
12151 static const int volume = 1;
12152 static const bool is_fixed_size = true;
12153 };
12154
12155 template<
12156 typename element_type_,
12157 int n0_,
12158 typename base_iterator_type_>
12159 struct array_signature_traits<
12160 element_type_[n0_],
12161 base_iterator_type_>
12162 {
12163 typedef element_type_ element_type;
12164 typedef typename detail::remove<element_type_, volatile const int>::type value_type;
12165 typedef value_type signature[n0_];
12166
12167 typedef typename detail::type_if<
12168 detail::same_type<base_iterator_type_, void>::result,
12169 element_type_*,
12170 base_iterator_type_
12171 >::type base_iterator_type;
12172
12173 typedef pack<
12174 base_iterator_type,
12175 constant<int, 1>
12176 > default_iterator;
12177
12178 typedef pack<
12179 base_iterator_type,
12180 constant<int, 1>
12181 > default_rev_iterator;
12182
12183 typedef pack<
12184 typename detail::type_if<n0_ == 1, int, constant<int, n0_> >::type
12185 > size_type;
12186
12187 static const int dimensions = 1;
12188 static const int volume = n0_;
12189 static const bool is_fixed_size = n0_!=1;
12190 };
12191
12192 template<
12193 typename element_type_,
12194 int n0_,
12195 int n1_,
12196 typename base_iterator_type_>
12197 struct array_signature_traits<
12198 element_type_[n0_][n1_],
12199 base_iterator_type_>
12200 {
12201 typedef element_type_ element_type;
12202 typedef typename detail::remove<element_type_, volatile const int>::type value_type;
12203 typedef value_type signature[n0_][n1_];
12204
12205 typedef typename detail::type_if<
12206 detail::same_type<base_iterator_type_, void>::result,
12207 element_type_*,
12208 base_iterator_type_
12209 >::type base_iterator_type;
12210
12211 typedef pack<
12212 base_iterator_type,
12213 typename detail::type_if<(n1_==1), int, constant<int, n1_> >::type,
12214 constant<int, 1>
12215 > default_iterator;
12216
12217 typedef pack<
12218 base_iterator_type,
12219 constant<int, 1>,
12220 typename detail::type_if<(n0_==1), int, constant<int, n0_> >::type
12221 > default_rev_iterator;
12222
12223 typedef pack<
12224 typename detail::type_if<n0_ == 1, int, constant<int, n0_> >::type,
12225 typename detail::type_if<n1_ == 1, int, constant<int, n1_> >::type
12226 > size_type;
12227
12228 static const int dimensions = 2;
12229 static const int volume = n0_ * n1_;
12230 static const bool is_fixed_size = n0_!=1 && n1_!=1;
12231 };
12232
12233 template<
12234 typename element_type_,
12235 int n0_,
12236 int n1_,
12237 int n2_,
12238 typename base_iterator_type_>
12239 struct array_signature_traits<
12240 element_type_[n0_][n1_][n2_],
12241 base_iterator_type_>
12242 {
12243 typedef element_type_ element_type;
12244 typedef typename detail::remove<element_type_, volatile const int>::type value_type;
12245 typedef value_type signature[n0_][n1_][n2_];
12246
12247 typedef typename detail::type_if<
12248 detail::same_type<base_iterator_type_, void>::result,
12249 element_type_*,
12250 base_iterator_type_
12251 >::type base_iterator_type;
12252
12253 typedef pack<
12254 base_iterator_type,
12255 typename detail::type_if<(n1_==1||n2_==1), int, constant<int, n1_*n2_> >::type,
12256 typename detail::type_if<(n2_==1), int, constant<int, n2_> >::type,
12257 constant<int, 1>
12258 > default_iterator;
12259
12260 typedef pack<
12261 base_iterator_type,
12262 constant<int, 1>,
12263 typename detail::type_if<(n0_==1), int, constant<int, n0_> >::type,
12264 typename detail::type_if<(n1_==1||n0_==1), int, constant<int, n1_*n0_> >::type
12265 > default_rev_iterator;
12266
12267 typedef pack<
12268 typename detail::type_if<n0_ == 1, int, constant<int, n0_> >::type,
12269 typename detail::type_if<n1_ == 1, int, constant<int, n1_> >::type,
12270 typename detail::type_if<n2_ == 1, int, constant<int, n2_> >::type
12271 > size_type;
12272
12273 static const int dimensions = 3;
12274 static const int volume = n0_ * n1_ * n2_;
12275 static const bool is_fixed_size = n0_!=1 && n1_!=1 && n2_!=1;
12276 };
12277
12278
12279
12280 template<
12281 typename element_type_,
12282 int n0_,
12283 int n1_,
12284 int n2_,
12285 int n3_,
12286 typename base_iterator_type_>
12287 struct array_signature_traits<
12288 element_type_[n0_][n1_][n2_][n3_],
12289 base_iterator_type_>
12290 {
12291 typedef element_type_ element_type;
12292 typedef typename detail::remove<element_type_, volatile const int>::type value_type;
12293 typedef value_type signature[n0_][n1_][n2_][n3_];
12294
12295
12296
12297
12298
12299
12300 static const int dimensions = 3+1;
12301 static const int volume = n0_ * n1_ * n2_ * n3_;
12302 static const bool is_fixed_size = n0_!=1 && n1_!=1 && n2_!=1 && n3_!=1;
12303 };
12304
12305 #endif // !DOCUMENTATION_ONLY
12306
12307
12308
12309
12310
12311 template<typename signature_, typename traits_type_>
12312 struct array_helper
12313 {
12314 typedef array<signature_, traits_type_,
12315 typename traits_type_::template representation_type<signature_>::temporary_type>
12316 temporary_array;
12317
12318 typedef array<signature_, traits_type_,
12319 typename traits_type_::template representation_type<signature_>::fwd_temporary_type>
12320 fwd_temporary_array;
12321
12322 typedef array<signature_, traits_type_,
12323 typename traits_type_::template representation_type<signature_>::rev_temporary_type>
12324 rev_temporary_array;
12325 };
12326
12327
12328
12329
12330
12331 namespace detail
12332 {
12333
12334 template<typename iterator_type_, int dim_=0>
12335 struct g_iterator_traits;
12336
12337
12338
12339
12340
12341 template<typename base_iterator_type_>
12342 struct g_iterator_traits<pack<base_iterator_type_>, 0>
12343 {
12344 typedef pack<base_iterator_type_> iterator_type;
12345
12346 static const int complexity = 1;
12347 static const int non_unit_strides_count = 0;
12348 static const int constant_strides_count = 0;
12349 static const int variable_strides_count = 0;
12350 };
12351
12352 template<
12353 typename base_iterator_type_,
12354 typename type0_,
12355 typename type1_,
12356 typename type2_
12357 >
12358 struct g_iterator_traits<
12359 pack<
12360 base_iterator_type_,
12361 type0_,
12362 type1_,
12363 type2_
12364 >,
12365 0
12366 >
12367 {
12368 typedef pack<
12369 base_iterator_type_,
12370 type0_,
12371 type1_,
12372 type2_
12373 > iterator_type;
12374
12375 static const int complexity = 2;
12376 static const int non_unit_strides_count =
12377 detail::same_type<type0_, constant<int, 1> >::result ? 0 : 1;
12378 static const int constant_strides_count = iterator_type::is_const1 ? 1 : 0;
12379 static const int variable_strides_count = iterator_type::is_const1 ? 0 : 1;
12380 };
12381 template<
12382 typename base_iterator_type_,
12383 typename type0_,
12384 typename type1_,
12385 typename type2_
12386 >
12387 struct g_iterator_traits<
12388 pack<
12389 base_iterator_type_,
12390 type0_,
12391 type1_,
12392 type2_
12393 >,
12394 1
12395 >
12396 {
12397 typedef pack<
12398 base_iterator_type_,
12399 type0_,
12400 type1_,
12401 type2_
12402 > iterator_type;
12403
12404 static const int complexity = 2;
12405 static const int non_unit_strides_count =
12406 detail::same_type<type1_, constant<int, 1> >::result ? 0 : 1;
12407 static const int constant_strides_count = iterator_type::is_const2 ? 1 : 0;
12408 static const int variable_strides_count = iterator_type::is_const2 ? 0 : 1;
12409 };
12410 template<
12411 typename base_iterator_type_,
12412 typename type0_,
12413 typename type1_,
12414 typename type2_
12415 >
12416 struct g_iterator_traits<
12417 pack<
12418 base_iterator_type_,
12419 type0_,
12420 type1_,
12421 type2_
12422 >,
12423 2
12424 >
12425 {
12426 typedef pack<
12427 base_iterator_type_,
12428 type0_,
12429 type1_,
12430 type2_
12431 > iterator_type;
12432
12433 static const int complexity = 2;
12434 static const int non_unit_strides_count =
12435 detail::same_type<type2_, constant<int, 1> >::result ? 0 : 1;
12436 static const int constant_strides_count = iterator_type::is_const3 ? 1 : 0;
12437 static const int variable_strides_count = iterator_type::is_const3 ? 0 : 1;
12438 };
12439
12440
12441
12442
12443
12444 template<typename value_type_, int dim_>
12445 struct g_iterator_traits<c_iterator<value_type_>, dim_>
12446 {
12447 typedef c_iterator<value_type_> iterator_type;
12448
12449 static const int complexity = 1;
12450 static const int non_unit_strides_count = 0;
12451 static const int constant_strides_count = 0;
12452 static const int variable_strides_count = 0;
12453 };
12454
12455
12456
12457
12458
12459 template<typename base_iter_type_, typename func_type_, bool is_static_, int dim_>
12460 struct g_iterator_traits<u_iterator<base_iter_type_, func_type_, is_static_>, dim_>
12461 {
12462 typedef u_iterator<base_iter_type_, func_type_, is_static_> iterator_type;
12463
12464 static const int complexity =
12465 g_iterator_traits<base_iter_type_, dim_>::complexity+1;
12466
12467 static const int non_unit_strides_count =
12468 g_iterator_traits<base_iter_type_, dim_>::non_unit_strides_count;
12469
12470 static const int constant_strides_count =
12471 g_iterator_traits<base_iter_type_, dim_>::constant_strides_count;
12472
12473 static const int variable_strides_count =
12474 g_iterator_traits<base_iter_type_, dim_>::variable_strides_count;
12475 };
12476
12477
12478
12479
12480
12481 template<
12482 typename left_base_iter_type_,
12483 typename right_base_iter_type_,
12484 typename func_type_,
12485 bool is_static_,
12486 int dim_>
12487 struct g_iterator_traits<
12488 b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_>, dim_>
12489 {
12490 typedef b_iterator<left_base_iter_type_, right_base_iter_type_, func_type_, is_static_> iterator_type;
12491
12492 static const int complexity =
12493 g_iterator_traits<left_base_iter_type_, dim_>::complexity
12494 +g_iterator_traits<right_base_iter_type_, dim_>::complexity+1;
12495
12496 static const int non_unit_strides_count =
12497 g_iterator_traits<left_base_iter_type_, dim_>::non_unit_strides_count
12498 +g_iterator_traits<right_base_iter_type_, dim_>::non_unit_strides_count;
12499
12500 static const int constant_strides_count =
12501 g_iterator_traits<left_base_iter_type_, dim_>::constant_strides_count
12502 +g_iterator_traits<right_base_iter_type_, dim_>::constant_strides_count;
12503
12504 static const int variable_strides_count =
12505 g_iterator_traits<left_base_iter_type_, dim_>::variable_strides_count
12506 +g_iterator_traits<right_base_iter_type_, dim_>::variable_strides_count;
12507 };
12508
12509
12510
12511
12512
12513 template<typename iterator_type_, int dim_=0>
12514 struct g_iterator_policy
12515 {
12516 typedef g_iterator_traits<iterator_type_, dim_> traits_type;
12517
12518 static const bool use_index = traits_type::constant_strides_count >= traits_type::variable_strides_count;
12519
12520 };
12521
12522
12523
12524
12525
12526 template<typename array_type_, int freq_>
12527 struct matrix_policy
12528 {};
12529
12530
12531
12532 template<typename value_type_, int n0_, typename traits_type_, typename _rep, int freq_>
12533 struct matrix_policy<array<value_type_[n0_], traits_type_, _rep>, freq_>
12534 {
12535 typedef array<value_type_[n0_], traits_type_, _rep> original_array_type;
12536
12537 typedef g_iterator_traits<typename original_array_type::iterator, 0> g_iterator_traits0;
12538
12539 static const bool should_cache_dim0 =
12540 freq_ <= 1 ? g_iterator_traits0::complexity > 8 :
12541 freq_ <= 2 ? g_iterator_traits0::complexity > 2 || g_iterator_traits0::variable_strides_count > 2 :
12542 g_iterator_traits0::complexity > 2
12543 || g_iterator_traits0::variable_strides_count > 0
12544 || g_iterator_traits0::non_unit_strides_count > 0;
12545
12546 typedef typename type_if<
12547 should_cache_dim0,
12548 typename array_helper<value_type_[n0_], traits_type_>::temporary_array,
12549 const original_array_type&
12550 >::type cached_array;
12551 };
12552
12553
12554
12555 template<typename value_type_, int n0_, int n1_, typename traits_type_, typename _rep, int freq_>
12556 struct matrix_policy<array<value_type_[n0_][n1_], traits_type_, _rep>, freq_>
12557 {
12558 typedef array<value_type_[n0_][n1_], traits_type_, _rep> original_array_type;
12559
12560 typedef g_iterator_traits<typename original_array_type::iterator, 0> g_iterator_traits0;
12561 typedef g_iterator_traits<typename original_array_type::iterator, 1> g_iterator_traits1;
12562
12563 static const bool should_cache_dim0 =
12564 freq_ <= 1 ? g_iterator_traits0::complexity > 8 :
12565 freq_ <= 2 ? g_iterator_traits0::complexity > 2 || g_iterator_traits0::variable_strides_count > 2 :
12566 g_iterator_traits0::complexity > 2
12567 || g_iterator_traits0::variable_strides_count > 0
12568 || g_iterator_traits0::non_unit_strides_count > 0;
12569
12570
12571 static const bool should_cache_dim1 =
12572 freq_ <= 1 ? g_iterator_traits1::complexity > 8 :
12573 freq_ <= 2 ? g_iterator_traits1::complexity > 2 || g_iterator_traits1::variable_strides_count > 2 :
12574 g_iterator_traits1::complexity > 2
12575 || g_iterator_traits1::variable_strides_count > 0
12576 || g_iterator_traits0::non_unit_strides_count > 0;
12577
12578 typedef typename type_if<
12579 should_cache_dim0,
12580 typename array_helper<value_type_[n0_][n1_], traits_type_>::fwd_temporary_array,
12581 const original_array_type&
12582 >::type cached_fwd_array;
12583
12584 typedef typename type_if<
12585 should_cache_dim1,
12586 typename array_helper<value_type_[n0_][n1_], traits_type_>::rev_temporary_array,
12587 const original_array_type&
12588 >::type cached_rev_array;
12589 };
12590
12591
12592
12593 template<typename value_type_, int n0_, int n1_, int n2_, typename traits_type_, typename _rep, int freq_>
12594 struct matrix_policy<array<value_type_[n0_][n1_][n2_], traits_type_, _rep>, freq_>
12595 {};
12596
12597 }
12598
12599
12600
12601
12602
12603 #ifdef DOCUMENTATION_ONLY
12604
12610 template<typename iterator_type_, typename size_type_>
12611 LITE_INLINE void for_each(const iterator_type_& iter, const size_type_& size);
12612
12619 template<typename iterator_type_, typename function_type_, typename size_type_>
12620 LITE_INLINE void for_each(const iterator_type_& iter, function_type_& func, const size_type_& size);
12621
12629 template<typename iterator_type_, typename size_type_>
12630 LITE_INLINE bool for_each_c(const iterator_type_& iter, const size_type_& size);
12631
12640 template<typename iterator_type_, typename function_type_, typename size_type_>
12641 LITE_INLINE bool for_each_c(const iterator_type_& iter, function_type_& func, const size_type_& size);
12642
12643 #else // DOCUMENTATION_ONLY
12644
12645
12646
12647
12648
12649 template<typename iterator_type_>
12650 LITE_INLINE void
12651 for_each(const iterator_type_& iter, const pack<>&)
12652 {
12653 at(iter);
12654 }
12655
12656 template<typename iterator_type_, typename function_type_>
12657 LITE_INLINE void
12658 for_each(const iterator_type_& iter, function_type_& func, const pack<>&)
12659 {
12660 func(at(iter));
12661 }
12662
12663 template<typename iterator_type_>
12664 LITE_INLINE bool
12665 for_each_c(const iterator_type_& iter, const pack<>&)
12666 {
12667 return at(iter);
12668 }
12669
12670 template<typename iterator_type_, typename function_type_>
12671 LITE_INLINE bool
12672 for_each_c(const iterator_type_& iter, function_type_& func, const pack<>&)
12673 {
12674 return func(at(iter));
12675 }
12676
12677
12678
12679
12680
12681
12682 template<typename iterator_type_>
12683 LITE_INLINE
12684 typename detail::enable_if<(
12685 detail::g_iterator_policy<iterator_type_>::use_index
12686 )>::type
12687 for_each(const iterator_type_& iter, const pack<constant<int, 1> >&)
12688 {
12689 at(iter, 0);
12690 }
12691
12692 template<typename iterator_type_, typename function_type_>
12693 LITE_INLINE
12694 typename detail::enable_if<(
12695 detail::g_iterator_policy<iterator_type_>::use_index
12696 )>::type
12697 for_each(const iterator_type_& iter, function_type_& func, const pack<constant<int, 1> >&)
12698 {
12699 func(at(iter, 0));
12700 }
12701
12702 template<typename iterator_type_, typename function_type_>
12703 LITE_INLINE
12704 typename detail::enable_if<(
12705 detail::g_iterator_policy<iterator_type_>::use_index
12706 ), bool>::type
12707 for_each_c(const iterator_type_& iter, function_type_& func, const pack<constant<int, 1> >&)
12708 {
12709 if (!func(at(iter, 0))) return false;
12710 return true;
12711 }
12712
12713 template<typename iterator_type_>
12714 LITE_INLINE
12715 typename detail::enable_if<(
12716 detail::g_iterator_policy<iterator_type_>::use_index
12717 ), bool>::type
12718 for_each_c(const iterator_type_& iter, const pack<constant<int, 1> >&)
12719 {
12720 if (!at(iter, 0)) return false;
12721 return true;
12722 }
12723
12724 template<typename iterator_type_>
12725 LITE_INLINE
12726 typename detail::enable_if<(
12727 detail::g_iterator_policy<iterator_type_>::use_index
12728 )>::type
12729 for_each(const iterator_type_& iter, const pack<constant<int, 2> >&)
12730 {
12731 at(iter, 0);
12732 at(iter, 1);
12733 }
12734
12735 template<typename iterator_type_, typename function_type_>
12736 LITE_INLINE
12737 typename detail::enable_if<(
12738 detail::g_iterator_policy<iterator_type_>::use_index
12739 )>::type
12740 for_each(const iterator_type_& iter, function_type_& func, const pack<constant<int, 2> >&)
12741 {
12742 func(at(iter, 0));
12743 func(at(iter, 1));
12744 }
12745
12746 template<typename iterator_type_, typename function_type_>
12747 LITE_INLINE
12748 typename detail::enable_if<(
12749 detail::g_iterator_policy<iterator_type_>::use_index
12750 ), bool>::type
12751 for_each_c(const iterator_type_& iter, function_type_& func, const pack<constant<int, 2> >&)
12752 {
12753 if (!func(at(iter, 0))) return false;
12754 if (!func(at(iter, 1))) return false;
12755 return true;
12756 }
12757
12758 template<typename iterator_type_>
12759 LITE_INLINE
12760 typename detail::enable_if<(
12761 detail::g_iterator_policy<iterator_type_>::use_index
12762 ), bool>::type
12763 for_each_c(const iterator_type_& iter, const pack<constant<int, 2> >&)
12764 {
12765 if (!at(iter, 0)) return false;
12766 if (!at(iter, 1)) return false;
12767 return true;
12768 }
12769
12770 template<typename iterator_type_>
12771 LITE_INLINE
12772 typename detail::enable_if<(
12773 detail::g_iterator_policy<iterator_type_>::use_index
12774 )>::type
12775 for_each(const iterator_type_& iter, const pack<constant<int, 3> >&)
12776 {
12777 at(iter, 0);
12778 at(iter, 1);
12779 at(iter, 2);
12780 }
12781
12782 template<typename iterator_type_, typename function_type_>
12783 LITE_INLINE
12784 typename detail::enable_if<(
12785 detail::g_iterator_policy<iterator_type_>::use_index
12786 )>::type
12787 for_each(const iterator_type_& iter, function_type_& func, const pack<constant<int, 3> >&)
12788 {
12789 func(at(iter, 0));
12790 func(at(iter, 1));
12791 func(at(iter, 2));
12792 }
12793
12794 template<typename iterator_type_, typename function_type_>
12795 LITE_INLINE
12796 typename detail::enable_if<(
12797 detail::g_iterator_policy<iterator_type_>::use_index
12798 ), bool>::type
12799 for_each_c(const iterator_type_& iter, function_type_& func, const pack<constant<int, 3> >&)
12800 {
12801 if (!func(at(iter, 0))) return false;
12802 if (!func(at(iter, 1))) return false;
12803 if (!func(at(iter, 2))) return false;
12804 return true;
12805 }
12806
12807 template<typename iterator_type_>
12808 LITE_INLINE
12809 typename detail::enable_if<(
12810 detail::g_iterator_policy<iterator_type_>::use_index
12811 ), bool>::type
12812 for_each_c(const iterator_type_& iter, const pack<constant<int, 3> >&)
12813 {
12814 if (!at(iter, 0)) return false;
12815 if (!at(iter, 1)) return false;
12816 if (!at(iter, 2)) return false;
12817 return true;
12818 }
12819
12820 template<typename iterator_type_>
12821 LITE_INLINE
12822 typename detail::enable_if<(
12823 detail::g_iterator_policy<iterator_type_>::use_index
12824 )>::type
12825 for_each(const iterator_type_& iter, const pack<constant<int, 4> >&)
12826 {
12827 at(iter, 0);
12828 at(iter, 1);
12829 at(iter, 2);
12830 at(iter, 3);
12831 }
12832
12833 template<typename iterator_type_, typename function_type_>
12834 LITE_INLINE
12835 typename detail::enable_if<(
12836 detail::g_iterator_policy<iterator_type_>::use_index
12837 )>::type
12838 for_each(const iterator_type_& iter, function_type_& func, const pack<constant<int, 4> >&)
12839 {
12840 func(at(iter, 0));
12841 func(at(iter, 1));
12842 func(at(iter, 2));
12843 func(at(iter, 3));
12844 }
12845
12846 template<typename iterator_type_, typename function_type_>
12847 LITE_INLINE
12848 typename detail::enable_if<(
12849 detail::g_iterator_policy<iterator_type_>::use_index
12850 ), bool>::type
12851 for_each_c(const iterator_type_& iter, function_type_& func, const pack<constant<int, 4> >&)
12852 {
12853 if (!func(at(iter, 0))) return false;
12854 if (!func(at(iter, 1))) return false;
12855 if (!func(at(iter, 2))) return false;
12856 if (!func(at(iter, 3))) return false;
12857 return true;
12858 }
12859
12860 template<typename iterator_type_>
12861 LITE_INLINE
12862 typename detail::enable_if<(
12863 detail::g_iterator_policy<iterator_type_>::use_index
12864 ), bool>::type
12865 for_each_c(const iterator_type_& iter, const pack<constant<int, 4> >&)
12866 {
12867 if (!at(iter, 0)) return false;
12868 if (!at(iter, 1)) return false;
12869 if (!at(iter, 2)) return false;
12870 if (!at(iter, 3)) return false;
12871 return true;
12872 }
12873
12874 template<typename iterator_type_>
12875 LITE_INLINE
12876 typename detail::enable_if<(
12877 detail::g_iterator_policy<iterator_type_>::use_index
12878 )>::type
12879 for_each(const iterator_type_& iter, const pack<constant<int, 5> >&)
12880 {
12881 at(iter, 0);
12882 at(iter, 1);
12883 at(iter, 2);
12884 at(iter, 3);
12885 at(iter, 4);
12886 }
12887
12888 template<typename iterator_type_, typename function_type_>
12889 LITE_INLINE
12890 typename detail::enable_if<(
12891 detail::g_iterator_policy<iterator_type_>::use_index
12892 )>::type
12893 for_each(const iterator_type_& iter, function_type_& func, const pack<constant<int, 5> >&)
12894 {
12895 func(at(iter, 0));
12896 func(at(iter, 1));
12897 func(at(iter, 2));
12898 func(at(iter, 3));
12899 func(at(iter, 4));
12900 }
12901
12902 template<typename iterator_type_, typename function_type_>
12903 LITE_INLINE
12904 typename detail::enable_if<(
12905 detail::g_iterator_policy<iterator_type_>::use_index
12906 ), bool>::type
12907 for_each_c(const iterator_type_& iter, function_type_& func, const pack<constant<int, 5> >&)
12908 {
12909 if (!func(at(iter, 0))) return false;
12910 if (!func(at(iter, 1))) return false;
12911 if (!func(at(iter, 2))) return false;
12912 if (!func(at(iter, 3))) return false;
12913 if (!func(at(iter, 4))) return false;
12914 return true;
12915 }
12916
12917 template<typename iterator_type_>
12918 LITE_INLINE
12919 typename detail::enable_if<(
12920 detail::g_iterator_policy<iterator_type_>::use_index
12921 ), bool>::type
12922 for_each_c(const iterator_type_& iter, const pack<constant<int, 5> >&)
12923 {
12924 if (!at(iter, 0)) return false;
12925 if (!at(iter, 1)) return false;
12926 if (!at(iter, 2)) return false;
12927 if (!at(iter, 3)) return false;
12928 if (!at(iter, 4)) return false;
12929 return true;
12930 }
12931
12932
12933
12934
12935
12936 template<typename iterator_type_>
12937 LITE_INLINE
12938 typename detail::enable_if<(
12939 !detail::g_iterator_policy<iterator_type_>::use_index
12940 )>::type
12941 for_each(const iterator_type_& iter, const pack<constant<int, 6> >&)
12942 {
12943 iterator_type_ it = iter;
12944
12945 at(it, 0); inc<0>(it);
12946 at(it, 1); inc<0>(it);
12947 at(it, 2); inc<0>(it);
12948 at(it, 3); inc<0>(it);
12949 at(it, 4); inc<0>(it);
12950 at(it, 5);
12951 }
12952
12953 template<typename iterator_type_, typename function_type_>
12954 LITE_INLINE
12955 typename detail::enable_if<(
12956 !detail::g_iterator_policy<iterator_type_>::use_index
12957 )>::type
12958 for_each(const iterator_type_& iter, function_type_& func, const pack<constant<int, 6> >&)
12959 {
12960 iterator_type_ it = iter;
12961
12962 func(at(it, 0)); inc<0>(it);
12963 func(at(it, 1)); inc<0>(it);
12964 func(at(it, 2)); inc<0>(it);
12965 func(at(it, 3)); inc<0>(it);
12966 func(at(it, 4)); inc<0>(it);
12967 func(at(it, 5));
12968 }
12969
12970 template<typename iterator_type_>
12971 LITE_INLINE
12972 typename detail::enable_if<(
12973 !detail::g_iterator_policy<iterator_type_>::use_index
12974 ), bool>::type
12975 for_each_c(const iterator_type_& iter, const pack<constant<int, 6> >&)
12976 {
12977 iterator_type_ it = iter;
12978
12979 if (!at(iter, 0)) return false; inc<0>(it);
12980 if (!at(iter, 1)) return false; inc<0>(it);
12981 if (!at(iter, 2)) return false; inc<0>(it);
12982 if (!at(iter, 3)) return false; inc<0>(it);
12983 if (!at(iter, 4)) return false; inc<0>(it);
12984 if (!at(iter, 5)) return false;
12985
12986 return true;
12987 }
12988
12989 template<typename iterator_type_, typename function_type_>
12990 LITE_INLINE
12991 typename detail::enable_if<(
12992 !detail::g_iterator_policy<iterator_type_>::use_index
12993 ), bool>::type
12994 for_each_c(const iterator_type_& iter, function_type_& func, const pack<constant<int, 6> >&)
12995 {
12996 iterator_type_ it = iter;
12997
12998 if (!func(at(iter, 0))) return false; inc<0>(it);
12999 if (!func(at(iter, 1))) return false; inc<0>(it);
13000 if (!func(at(iter, 2))) return false; inc<0>(it);
13001 if (!func(at(iter, 3))) return false; inc<0>(it);
13002 if (!func(at(iter, 4))) return false; inc<0>(it);
13003 if (!func(at(iter, 5))) return false;
13004
13005 return true;
13006 }
13007
13008
13009
13010
13011
13012 template<typename iterator_type_, typename type_>
13013 LITE_INLINE
13014 typename detail::enable_if<(
13015 detail::g_iterator_policy<iterator_type_>::use_index
13016 )>::type
13017 for_each(const iterator_type_& iter, const pack<type_>& size)
13018 {
13019 const int n = size.i0;
13020 int j=16;
13021 iterator_type_ it = iter;
13022
13023 for (; j<=n; j+=16) {
13024 at(it, 0);
13025 at(it, 1);
13026 at(it, 2);
13027 at(it, 3);
13028 at(it, 4);
13029 at(it, 5);
13030 at(it, 6);
13031 at(it, 7);
13032 at(it, 8);
13033 at(it, 9);
13034 at(it, 10);
13035 at(it, 11);
13036 at(it, 12);
13037 at(it, 13);
13038 at(it, 14);
13039 at(it, 15);
13040 shift<0>(it, 16);
13041 }
13042
13043 if (n & 8) {
13044 at(it, 0);
13045 at(it, 1);
13046 at(it, 2);
13047 at(it, 3);
13048 at(it, 4);
13049 at(it, 5);
13050 at(it, 6);
13051 at(it, 7);
13052 shift<0>(it, 8);
13053 }
13054 if (n & 4) {
13055 at(it, 0);
13056 at(it, 1);
13057 at(it, 2);
13058 at(it, 3);
13059 shift<0>(it, 4);
13060 }
13061 if (n & 2) {
13062 at(it, 0);
13063 at(it, 1);
13064 shift<0>(it, 2);
13065 }
13066
13067 if (n & 1)
13068 at(it, 0);
13069
13070 LITE_ARRAY_USE(size);
13071 }
13072
13073 template<typename iterator_type_, typename function_type_, typename type_>
13074 LITE_INLINE
13075 typename detail::enable_if<(
13076 detail::g_iterator_policy<iterator_type_>::use_index
13077 )>::type
13078 for_each(const iterator_type_& iter, function_type_& func, const pack<type_>& size)
13079 {
13080 const int n = size.i0;
13081 int j=16;
13082 iterator_type_ it = iter;
13083
13084 for (; j<=n; j+=16) {
13085 func(at(it, 0));
13086 func(at(it, 1));
13087 func(at(it, 2));
13088 func(at(it, 3));
13089 func(at(it, 4));
13090 func(at(it, 5));
13091 func(at(it, 6));
13092 func(at(it, 7));
13093 func(at(it, 8));
13094 func(at(it, 9));
13095 func(at(it, 10));
13096 func(at(it, 11));
13097 func(at(it, 12));
13098 func(at(it, 13));
13099 func(at(it, 14));
13100 func(at(it, 15));
13101 shift<0>(it, 16);
13102 }
13103
13104 if (n & 8) {
13105 func(at(it, 0));
13106 func(at(it, 1));
13107 func(at(it, 2));
13108 func(at(it, 3));
13109 func(at(it, 4));
13110 func(at(it, 5));
13111 func(at(it, 6));
13112 func(at(it, 7));
13113 shift<0>(it, 8);
13114 }
13115 if (n & 4) {
13116 func(at(it, 0));
13117 func(at(it, 1));
13118 func(at(it, 2));
13119 func(at(it, 3));
13120 shift<0>(it, 4);
13121 }
13122 if (n & 2) {
13123 func(at(it, 0));
13124 func(at(it, 1));
13125 shift<0>(it, 2);
13126 }
13127
13128 if (n & 1)
13129 func(at(it, 0));
13130
13131 LITE_ARRAY_USE(size);
13132 }
13133
13134 template<typename iterator_type_, typename type_>
13135 LITE_INLINE
13136 typename detail::enable_if<(
13137 detail::g_iterator_policy<iterator_type_>::use_index
13138 ), bool>::type
13139 for_each_c(const iterator_type_& iter, const pack<type_>& size)
13140 {
13141 const int n = size.i0;
13142 int j=16;
13143 iterator_type_ it = iter;
13144
13145 for (; j<=n; j+=16) {
13146 if (!at(it, 0)) return false;
13147 if (!at(it, 1)) return false;
13148 if (!at(it, 2)) return false;
13149 if (!at(it, 3)) return false;
13150 if (!at(it, 4)) return false;
13151 if (!at(it, 5)) return false;
13152 if (!at(it, 6)) return false;
13153 if (!at(it, 7)) return false;
13154 if (!at(it, 8)) return false;
13155 if (!at(it, 9)) return false;
13156 if (!at(it, 10)) return false;
13157 if (!at(it, 11)) return false;
13158 if (!at(it, 12)) return false;
13159 if (!at(it, 13)) return false;
13160 if (!at(it, 14)) return false;
13161 if (!at(it, 15)) return false;
13162 shift<0>(it, 16);
13163 }
13164
13165 if (n & 8) {
13166 if (!at(it, 0)) return false;
13167 if (!at(it, 1)) return false;
13168 if (!at(it, 2)) return false;
13169 if (!at(it, 3)) return false;
13170 if (!at(it, 4)) return false;
13171 if (!at(it, 5)) return false;
13172 if (!at(it, 6)) return false;
13173 if (!at(it, 7)) return false;
13174 shift<0>(it, 8);
13175 }
13176 if (n & 4) {
13177 if (!at(it, 0)) return false;
13178 if (!at(it, 1)) return false;
13179 if (!at(it, 2)) return false;
13180 if (!at(it, 3)) return false;
13181 shift<0>(it, 4);
13182 }
13183 if (n & 2) {
13184 if (!at(it, 0)) return false;
13185 if (!at(it, 1)) return false;
13186 shift<0>(it, 2);
13187 }
13188
13189 if (n & 1)
13190 if (!at(it, 0)) return false;
13191
13192 return true;
13193 LITE_ARRAY_USE(size);
13194 }
13195
13196 template<typename iterator_type_, typename function_type_, typename type_>
13197 LITE_INLINE
13198 typename detail::enable_if<(
13199 detail::g_iterator_policy<iterator_type_>::use_index
13200 ), bool>::type
13201 for_each_c(const iterator_type_& iter, function_type_& func, const pack<type_>& size)
13202 {
13203 const int n = size.i0;
13204 int j=16;
13205 iterator_type_ it = iter;
13206
13207 for (; j<=n; j+=16) {
13208 if (!func(at(it, 0))) return false;
13209 if (!func(at(it, 1))) return false;
13210 if (!func(at(it, 2))) return false;
13211 if (!func(at(it, 3))) return false;
13212 if (!func(at(it, 4))) return false;
13213 if (!func(at(it, 5))) return false;
13214 if (!func(at(it, 6))) return false;
13215 if (!func(at(it, 7))) return false;
13216 if (!func(at(it, 8))) return false;
13217 if (!func(at(it, 9))) return false;
13218 if (!func(at(it, 10))) return false;
13219 if (!func(at(it, 11))) return false;
13220 if (!func(at(it, 12))) return false;
13221 if (!func(at(it, 13))) return false;
13222 if (!func(at(it, 14))) return false;
13223 if (!func(at(it, 15))) return false;
13224 shift<0>(it, 16);
13225 }
13226
13227 if (n & 8) {
13228 if (!func(at(it, 0))) return false;
13229 if (!func(at(it, 1))) return false;
13230 if (!func(at(it, 2))) return false;
13231 if (!func(at(it, 3))) return false;
13232 if (!func(at(it, 4))) return false;
13233 if (!func(at(it, 5))) return false;
13234 if (!func(at(it, 6))) return false;
13235 if (!func(at(it, 7))) return false;
13236 shift<0>(it, 8);
13237 }
13238 if (n & 4) {
13239 if (!func(at(it, 0))) return false;
13240 if (!func(at(it, 1))) return false;
13241 if (!func(at(it, 2))) return false;
13242 if (!func(at(it, 3))) return false;
13243 shift<0>(it, 4);
13244 }
13245 if (n & 2) {
13246 if (!func(at(it, 0))) return false;
13247 if (!func(at(it, 1))) return false;
13248 shift<0>(it, 2);
13249 }
13250
13251 if (n & 1)
13252 if (!func(at(it, 0))) return false;
13253
13254 return true;
13255 LITE_ARRAY_USE(size);
13256 }
13257
13258
13259
13260
13261
13262 template<typename iterator_type_, typename type_>
13263 LITE_INLINE
13264 typename detail::enable_if<(
13265 !detail::g_iterator_policy<iterator_type_>::use_index
13266 )>::type
13267 for_each(const iterator_type_& iter, const pack<type_>& size)
13268 {
13269 const int n = size.i0;
13270 int j=16;
13271 iterator_type_ it = iter;
13272
13273 for (; j<=n; j+=16) {
13274 at(it); inc<0>(it);
13275 at(it); inc<0>(it);
13276 at(it); inc<0>(it);
13277 at(it); inc<0>(it);
13278 at(it); inc<0>(it);
13279 at(it); inc<0>(it);
13280 at(it); inc<0>(it);
13281 at(it); inc<0>(it);
13282 at(it); inc<0>(it);
13283 at(it); inc<0>(it);
13284 at(it); inc<0>(it);
13285 at(it); inc<0>(it);
13286 at(it); inc<0>(it);
13287 at(it); inc<0>(it);
13288 at(it); inc<0>(it);
13289 at(it); inc<0>(it);
13290 }
13291
13292 if (n & 8) {
13293 at(it); inc<0>(it);
13294 at(it); inc<0>(it);
13295 at(it); inc<0>(it);
13296 at(it); inc<0>(it);
13297 at(it); inc<0>(it);
13298 at(it); inc<0>(it);
13299 at(it); inc<0>(it);
13300 at(it); inc<0>(it);
13301 }
13302 if (n & 4) {
13303 at(it); inc<0>(it);
13304 at(it); inc<0>(it);
13305 at(it); inc<0>(it);
13306 at(it); inc<0>(it);
13307 }
13308 if (n & 2) {
13309 at(it); inc<0>(it);
13310 at(it); inc<0>(it);
13311 }
13312
13313 if (n & 1)
13314 at(it);
13315 LITE_ARRAY_USE(size);
13316 }
13317
13318 template<typename iterator_type_, typename function_type_, typename type_>
13319 LITE_INLINE
13320 typename detail::enable_if<(
13321 !detail::g_iterator_policy<iterator_type_>::use_index
13322 )>::type
13323 for_each(const iterator_type_& iter, function_type_& func, const pack<type_>& size)
13324 {
13325 const int n = size.i0;
13326 int j=16;
13327 iterator_type_ it = iter;
13328
13329 for (; j<=n; j+=16) {
13330 func(at(it)); inc<0>(it);
13331 func(at(it)); inc<0>(it);
13332 func(at(it)); inc<0>(it);
13333 func(at(it)); inc<0>(it);
13334 func(at(it)); inc<0>(it);
13335 func(at(it)); inc<0>(it);
13336 func(at(it)); inc<0>(it);
13337 func(at(it)); inc<0>(it);
13338 func(at(it)); inc<0>(it);
13339 func(at(it)); inc<0>(it);
13340 func(at(it)); inc<0>(it);
13341 func(at(it)); inc<0>(it);
13342 func(at(it)); inc<0>(it);
13343 func(at(it)); inc<0>(it);
13344 func(at(it)); inc<0>(it);
13345 func(at(it)); inc<0>(it);
13346 }
13347
13348 if (n & 8) {
13349 func(at(it)); inc<0>(it);
13350 func(at(it)); inc<0>(it);
13351 func(at(it)); inc<0>(it);
13352 func(at(it)); inc<0>(it);
13353 func(at(it)); inc<0>(it);
13354 func(at(it)); inc<0>(it);
13355 func(at(it)); inc<0>(it);
13356 func(at(it)); inc<0>(it);
13357 }
13358 if (n & 4) {
13359 func(at(it)); inc<0>(it);
13360 func(at(it)); inc<0>(it);
13361 func(at(it)); inc<0>(it);
13362 func(at(it)); inc<0>(it);
13363 }
13364 if (n & 2) {
13365 func(at(it)); inc<0>(it);
13366 func(at(it)); inc<0>(it);
13367 }
13368
13369 if (n & 1)
13370 func(at(it));
13371 LITE_ARRAY_USE(size);
13372 }
13373
13374 template<typename iterator_type_, typename type_>
13375 LITE_INLINE
13376 typename detail::enable_if<(
13377 !detail::g_iterator_policy<iterator_type_>::use_index
13378 ), bool>::type
13379 for_each_c(const iterator_type_& iter, const pack<type_>& size)
13380 {
13381 const int n = size.i0;
13382 int j=16;
13383 iterator_type_ it = iter;
13384
13385 for (; j<=n; j+=16) {
13386 if(!at(it)) return false; inc<0>(it);
13387 if(!at(it)) return false; inc<0>(it);
13388 if(!at(it)) return false; inc<0>(it);
13389 if(!at(it)) return false; inc<0>(it);
13390 if(!at(it)) return false; inc<0>(it);
13391 if(!at(it)) return false; inc<0>(it);
13392 if(!at(it)) return false; inc<0>(it);
13393 if(!at(it)) return false; inc<0>(it);
13394 if(!at(it)) return false; inc<0>(it);
13395 if(!at(it)) return false; inc<0>(it);
13396 if(!at(it)) return false; inc<0>(it);
13397 if(!at(it)) return false; inc<0>(it);
13398 if(!at(it)) return false; inc<0>(it);
13399 if(!at(it)) return false; inc<0>(it);
13400 if(!at(it)) return false; inc<0>(it);
13401 if(!at(it)) return false; inc<0>(it);
13402 }
13403
13404 if (n & 8) {
13405 if(!at(it)) return false; inc<0>(it);
13406 if(!at(it)) return false; inc<0>(it);
13407 if(!at(it)) return false; inc<0>(it);
13408 if(!at(it)) return false; inc<0>(it);
13409 if(!at(it)) return false; inc<0>(it);
13410 if(!at(it)) return false; inc<0>(it);
13411 if(!at(it)) return false; inc<0>(it);
13412 if(!at(it)) return false; inc<0>(it);
13413 }
13414 if (n & 4) {
13415 if(!at(it)) return false; inc<0>(it);
13416 if(!at(it)) return false; inc<0>(it);
13417 if(!at(it)) return false; inc<0>(it);
13418 if(!at(it)) return false; inc<0>(it);
13419 }
13420 if (n & 2) {
13421 if(!at(it)) return false; inc<0>(it);
13422 if(!at(it)) return false; inc<0>(it);
13423 }
13424
13425 if (n & 1)
13426 if(!at(it)) return false;
13427
13428 return true;
13429 LITE_ARRAY_USE(size);
13430 }
13431
13432
13433 template<typename iterator_type_, typename function_type_, typename type_>
13434 LITE_INLINE
13435 typename detail::enable_if<(
13436 !detail::g_iterator_policy<iterator_type_>::use_index
13437 ), bool>::type
13438 for_each_c(const iterator_type_& iter, function_type_& func, const pack<type_>& size)
13439 {
13440 const int n = size.i0;
13441 int j=16;
13442 iterator_type_ it = iter;
13443
13444 for (; j<=n; j+=16) {
13445 if(!func(at(it))) return false; inc<0>(it);
13446 if(!func(at(it))) return false; inc<0>(it);
13447 if(!func(at(it))) return false; inc<0>(it);
13448 if(!func(at(it))) return false; inc<0>(it);
13449 if(!func(at(it))) return false; inc<0>(it);
13450 if(!func(at(it))) return false; inc<0>(it);
13451 if(!func(at(it))) return false; inc<0>(it);
13452 if(!func(at(it))) return false; inc<0>(it);
13453 if(!func(at(it))) return false; inc<0>(it);
13454 if(!func(at(it))) return false; inc<0>(it);
13455 if(!func(at(it))) return false; inc<0>(it);
13456 if(!func(at(it))) return false; inc<0>(it);
13457 if(!func(at(it))) return false; inc<0>(it);
13458 if(!func(at(it))) return false; inc<0>(it);
13459 if(!func(at(it))) return false; inc<0>(it);
13460 if(!func(at(it))) return false; inc<0>(it);
13461 }
13462
13463 if (n & 8) {
13464 if(!func(at(it))) return false; inc<0>(it);
13465 if(!func(at(it))) return false; inc<0>(it);
13466 if(!func(at(it))) return false; inc<0>(it);
13467 if(!func(at(it))) return false; inc<0>(it);
13468 if(!func(at(it))) return false; inc<0>(it);
13469 if(!func(at(it))) return false; inc<0>(it);
13470 if(!func(at(it))) return false; inc<0>(it);
13471 if(!func(at(it))) return false; inc<0>(it);
13472 }
13473 if (n & 4) {
13474 if(!func(at(it))) return false; inc<0>(it);
13475 if(!func(at(it))) return false; inc<0>(it);
13476 if(!func(at(it))) return false; inc<0>(it);
13477 if(!func(at(it))) return false; inc<0>(it);
13478 }
13479 if (n & 2) {
13480 if(!func(at(it))) return false; inc<0>(it);
13481 if(!func(at(it))) return false; inc<0>(it);
13482 }
13483
13484 if (n & 1)
13485 if(!func(at(it))) return false; inc<0>(it);
13486
13487 return true;
13488 LITE_ARRAY_USE(size);
13489 }
13490
13491
13492
13493
13494
13495
13496 template<typename iterator_type_>
13497 LITE_INLINE
13498 typename detail::enable_if<(
13499 detail::g_iterator_policy<iterator_type_>::use_index
13500 )>::type
13501 for_each(const iterator_type_& iter, const pack<constant<int, 1>, constant<int, 1> >&)
13502 {
13503 at(iter, 0, 0);
13504 }
13505
13506 template<typename iterator_type_, typename function_type_>
13507 LITE_INLINE
13508 typename detail::enable_if<(
13509 detail::g_iterator_policy<iterator_type_>::use_index
13510 )>::type
13511 for_each(
13512 const iterator_type_& iter,
13513 function_type_& func,
13514 const pack<constant<int, 1>, constant<int, 1> >&)
13515 {
13516 func(at(iter, 0, 0));
13517 }
13518
13519 template<typename iterator_type_>
13520 LITE_INLINE
13521 typename detail::enable_if<(
13522 detail::g_iterator_policy<iterator_type_>::use_index
13523 ), bool>::type
13524 for_each_c(
13525 const iterator_type_& iter,
13526 const pack<constant<int, 1>, constant<int, 1> >&)
13527 {
13528 if (!at(iter, 0, 0)) return false;
13529 return true;
13530 }
13531
13532 template<typename iterator_type_, typename function_type_>
13533 LITE_INLINE
13534 typename detail::enable_if<(
13535 detail::g_iterator_policy<iterator_type_>::use_index
13536 ), bool>::type
13537 for_each_c(
13538 const iterator_type_& iter,
13539 function_type_& func,
13540 const pack<constant<int, 1>, constant<int, 1> >&)
13541 {
13542 if (!func(at(iter, 0, 0))) return false;
13543 return true;
13544 }
13545
13546 template<typename iterator_type_>
13547 LITE_INLINE
13548 typename detail::enable_if<(
13549 detail::g_iterator_policy<iterator_type_>::use_index
13550 )>::type
13551 for_each(const iterator_type_& iter, const pack<constant<int, 2>, constant<int, 2> >&)
13552 {
13553 at(iter, 0, 0);
13554 at(iter, 0, 1);
13555 at(iter, 1, 0);
13556 at(iter, 1, 1);
13557 }
13558
13559 template<typename iterator_type_, typename function_type_>
13560 LITE_INLINE
13561 typename detail::enable_if<(
13562 detail::g_iterator_policy<iterator_type_>::use_index
13563 )>::type
13564 for_each(
13565 const iterator_type_& iter,
13566 function_type_& func,
13567 const pack<constant<int, 2>, constant<int, 2> >&)
13568 {
13569 func(at(iter, 0, 0));
13570 func(at(iter, 0, 1));
13571 func(at(iter, 1, 0));
13572 func(at(iter, 1, 1));
13573 }
13574
13575 template<typename iterator_type_>
13576 LITE_INLINE
13577 typename detail::enable_if<(
13578 detail::g_iterator_policy<iterator_type_>::use_index
13579 ), bool>::type
13580 for_each_c(
13581 const iterator_type_& iter,
13582 const pack<constant<int, 2>, constant<int, 2> >&)
13583 {
13584 if (!at(iter, 0, 0)) return false;
13585 if (!at(iter, 0, 1)) return false;
13586 if (!at(iter, 1, 0)) return false;
13587 if (!at(iter, 1, 1)) return false;
13588 return true;
13589 }
13590
13591 template<typename iterator_type_, typename function_type_>
13592 LITE_INLINE
13593 typename detail::enable_if<(
13594 detail::g_iterator_policy<iterator_type_>::use_index
13595 ), bool>::type
13596 for_each_c(
13597 const iterator_type_& iter,
13598 function_type_& func,
13599 const pack<constant<int, 2>, constant<int, 2> >&)
13600 {
13601 if (!func(at(iter, 0, 0))) return false;
13602 if (!func(at(iter, 0, 1))) return false;
13603 if (!func(at(iter, 1, 0))) return false;
13604 if (!func(at(iter, 1, 1))) return false;
13605 return true;
13606 }
13607
13608 template<typename iterator_type_>
13609 LITE_INLINE
13610 typename detail::enable_if<(
13611 detail::g_iterator_policy<iterator_type_>::use_index
13612 )>::type
13613 for_each(const iterator_type_& iter, const pack<constant<int, 3>, constant<int, 3> >&)
13614 {
13615 at(iter, 0, 0);
13616 at(iter, 0, 1);
13617 at(iter, 0, 2);
13618 at(iter, 1, 0);
13619 at(iter, 1, 1);
13620 at(iter, 1, 2);
13621 at(iter, 2, 0);
13622 at(iter, 2, 1);
13623 at(iter, 2, 2);
13624 }
13625
13626 template<typename iterator_type_, typename function_type_>
13627 LITE_INLINE
13628 typename detail::enable_if<(
13629 detail::g_iterator_policy<iterator_type_>::use_index
13630 )>::type
13631 for_each(
13632 const iterator_type_& iter,
13633 function_type_& func,
13634 const pack<constant<int, 3>, constant<int, 3> >&)
13635 {
13636 func(at(iter, 0, 0));
13637 func(at(iter, 0, 1));
13638 func(at(iter, 0, 2));
13639 func(at(iter, 1, 0));
13640 func(at(iter, 1, 1));
13641 func(at(iter, 1, 2));
13642 func(at(iter, 2, 0));
13643 func(at(iter, 2, 1));
13644 func(at(iter, 2, 2));
13645 }
13646
13647 template<typename iterator_type_>
13648 LITE_INLINE
13649 typename detail::enable_if<(
13650 detail::g_iterator_policy<iterator_type_>::use_index
13651 ), bool>::type
13652 for_each_c(
13653 const iterator_type_& iter,
13654 const pack<constant<int, 3>, constant<int, 3> >&)
13655 {
13656 if (!at(iter, 0, 0)) return false;
13657 if (!at(iter, 0, 1)) return false;
13658 if (!at(iter, 0, 2)) return false;
13659 if (!at(iter, 1, 0)) return false;
13660 if (!at(iter, 1, 1)) return false;
13661 if (!at(iter, 1, 2)) return false;
13662 if (!at(iter, 2, 0)) return false;
13663 if (!at(iter, 2, 1)) return false;
13664 if (!at(iter, 2, 2)) return false;
13665 return true;
13666 }
13667
13668 template<typename iterator_type_, typename function_type_>
13669 LITE_INLINE
13670 typename detail::enable_if<(
13671 detail::g_iterator_policy<iterator_type_>::use_index
13672 ), bool>::type
13673 for_each_c(
13674 const iterator_type_& iter,
13675 function_type_& func,
13676 const pack<constant<int, 3>, constant<int, 3> >&)
13677 {
13678 if (!func(at(iter, 0, 0))) return false;
13679 if (!func(at(iter, 0, 1))) return false;
13680 if (!func(at(iter, 0, 2))) return false;
13681 if (!func(at(iter, 1, 0))) return false;
13682 if (!func(at(iter, 1, 1))) return false;
13683 if (!func(at(iter, 1, 2))) return false;
13684 if (!func(at(iter, 2, 0))) return false;
13685 if (!func(at(iter, 2, 1))) return false;
13686 if (!func(at(iter, 2, 2))) return false;
13687 return true;
13688 }
13689
13690 template<typename iterator_type_>
13691 LITE_INLINE
13692 typename detail::enable_if<(
13693 detail::g_iterator_policy<iterator_type_>::use_index
13694 )>::type
13695 for_each(const iterator_type_& iter, const pack<constant<int, 4>, constant<int, 4> >&)
13696 {
13697 at(iter, 0, 0);
13698 at(iter, 0, 1);
13699 at(iter, 0, 2);
13700 at(iter, 0, 3);
13701 at(iter, 1, 0);
13702 at(iter, 1, 1);
13703 at(iter, 1, 2);
13704 at(iter, 1, 3);
13705 at(iter, 2, 0);
13706 at(iter, 2, 1);
13707 at(iter, 2, 2);
13708 at(iter, 2, 3);
13709 at(iter, 3, 0);
13710 at(iter, 3, 1);
13711 at(iter, 3, 2);
13712 at(iter, 3, 3);
13713 }
13714
13715 template<typename iterator_type_, typename function_type_>
13716 LITE_INLINE
13717 typename detail::enable_if<(
13718 detail::g_iterator_policy<iterator_type_>::use_index
13719 )>::type
13720 for_each(
13721 const iterator_type_& iter,
13722 function_type_& func,
13723 const pack<constant<int, 4>, constant<int, 4> >&)
13724 {
13725 func(at(iter, 0, 0));
13726 func(at(iter, 0, 1));
13727 func(at(iter, 0, 2));
13728 func(at(iter, 0, 3));
13729 func(at(iter, 1, 0));
13730 func(at(iter, 1, 1));
13731 func(at(iter, 1, 2));
13732 func(at(iter, 1, 3));
13733 func(at(iter, 2, 0));
13734 func(at(iter, 2, 1));
13735 func(at(iter, 2, 2));
13736 func(at(iter, 2, 3));
13737 func(at(iter, 3, 0));
13738 func(at(iter, 3, 1));
13739 func(at(iter, 3, 2));
13740 func(at(iter, 3, 3));
13741 }
13742
13743 template<typename iterator_type_>
13744 LITE_INLINE
13745 typename detail::enable_if<(
13746 detail::g_iterator_policy<iterator_type_>::use_index
13747 ), bool>::type
13748 for_each_c(
13749 const iterator_type_& iter,
13750 const pack<constant<int, 4>, constant<int, 4> >&)
13751 {
13752 if (!at(iter, 0, 0)) return false;
13753 if (!at(iter, 0, 1)) return false;
13754 if (!at(iter, 0, 2)) return false;
13755 if (!at(iter, 0, 3)) return false;
13756 if (!at(iter, 1, 0)) return false;
13757 if (!at(iter, 1, 1)) return false;
13758 if (!at(iter, 1, 2)) return false;
13759 if (!at(iter, 1, 3)) return false;
13760 if (!at(iter, 2, 0)) return false;
13761 if (!at(iter, 2, 1)) return false;
13762 if (!at(iter, 2, 2)) return false;
13763 if (!at(iter, 2, 3)) return false;
13764 if (!at(iter, 3, 0)) return false;
13765 if (!at(iter, 3, 1)) return false;
13766 if (!at(iter, 3, 2)) return false;
13767 if (!at(iter, 3, 3)) return false;
13768 return true;
13769 }
13770
13771 template<typename iterator_type_, typename function_type_>
13772 LITE_INLINE
13773 typename detail::enable_if<(
13774 detail::g_iterator_policy<iterator_type_>::use_index
13775 ), bool>::type
13776 for_each_c(
13777 const iterator_type_& iter,
13778 function_type_& func,
13779 const pack<constant<int, 4>, constant<int, 4> >&)
13780 {
13781 if (!func(at(iter, 0, 0))) return false;
13782 if (!func(at(iter, 0, 1))) return false;
13783 if (!func(at(iter, 0, 2))) return false;
13784 if (!func(at(iter, 0, 3))) return false;
13785 if (!func(at(iter, 1, 0))) return false;
13786 if (!func(at(iter, 1, 1))) return false;
13787 if (!func(at(iter, 1, 2))) return false;
13788 if (!func(at(iter, 1, 3))) return false;
13789 if (!func(at(iter, 2, 0))) return false;
13790 if (!func(at(iter, 2, 1))) return false;
13791 if (!func(at(iter, 2, 2))) return false;
13792 if (!func(at(iter, 2, 3))) return false;
13793 if (!func(at(iter, 3, 0))) return false;
13794 if (!func(at(iter, 3, 1))) return false;
13795 if (!func(at(iter, 3, 2))) return false;
13796 if (!func(at(iter, 3, 3))) return false;
13797 return true;
13798 }
13799
13800 template<typename iterator_type_>
13801 LITE_INLINE
13802 typename detail::enable_if<(
13803 detail::g_iterator_policy<iterator_type_>::use_index
13804 )>::type
13805 for_each(const iterator_type_& iter, const pack<constant<int, 5>, constant<int, 5> >&)
13806 {
13807 at(iter, 0, 0);
13808 at(iter, 0, 1);
13809 at(iter, 0, 2);
13810 at(iter, 0, 3);
13811 at(iter, 0, 4);
13812 at(iter, 1, 0);
13813 at(iter, 1, 1);
13814 at(iter, 1, 2);
13815 at(iter, 1, 3);
13816 at(iter, 1, 4);
13817 at(iter, 2, 0);
13818 at(iter, 2, 1);
13819 at(iter, 2, 2);
13820 at(iter, 2, 3);
13821 at(iter, 2, 4);
13822 at(iter, 3, 0);
13823 at(iter, 3, 1);
13824 at(iter, 3, 2);
13825 at(iter, 3, 3);
13826 at(iter, 3, 4);
13827 at(iter, 4, 0);
13828 at(iter, 4, 1);
13829 at(iter, 4, 2);
13830 at(iter, 4, 3);
13831 at(iter, 4, 4);
13832 }
13833
13834 template<typename iterator_type_, typename function_type_>
13835 LITE_INLINE
13836 typename detail::enable_if<(
13837 detail::g_iterator_policy<iterator_type_>::use_index
13838 )>::type
13839 for_each(
13840 const iterator_type_& iter,
13841 function_type_& func,
13842 const pack<constant<int, 5>, constant<int, 5> >&)
13843 {
13844 func(at(iter, 0, 0));
13845 func(at(iter, 0, 1));
13846 func(at(iter, 0, 2));
13847 func(at(iter, 0, 3));
13848 func(at(iter, 0, 4));
13849 func(at(iter, 1, 0));
13850 func(at(iter, 1, 1));
13851 func(at(iter, 1, 2));
13852 func(at(iter, 1, 3));
13853 func(at(iter, 1, 4));
13854 func(at(iter, 2, 0));
13855 func(at(iter, 2, 1));
13856 func(at(iter, 2, 2));
13857 func(at(iter, 2, 3));
13858 func(at(iter, 2, 4));
13859 func(at(iter, 3, 0));
13860 func(at(iter, 3, 1));
13861 func(at(iter, 3, 2));
13862 func(at(iter, 3, 3));
13863 func(at(iter, 3, 4));
13864 func(at(iter, 4, 0));
13865 func(at(iter, 4, 1));
13866 func(at(iter, 4, 2));
13867 func(at(iter, 4, 3));
13868 func(at(iter, 4, 4));
13869 }
13870
13871 template<typename iterator_type_>
13872 LITE_INLINE
13873 typename detail::enable_if<(
13874 detail::g_iterator_policy<iterator_type_>::use_index
13875 ), bool>::type
13876 for_each_c(
13877 const iterator_type_& iter,
13878 const pack<constant<int, 5>, constant<int, 5> >&)
13879 {
13880 if (!at(iter, 0, 0)) return false;
13881 if (!at(iter, 0, 1)) return false;
13882 if (!at(iter, 0, 2)) return false;
13883 if (!at(iter, 0, 3)) return false;
13884 if (!at(iter, 0, 4)) return false;
13885 if (!at(iter, 1, 0)) return false;
13886 if (!at(iter, 1, 1)) return false;
13887 if (!at(iter, 1, 2)) return false;
13888 if (!at(iter, 1, 3)) return false;
13889 if (!at(iter, 1, 4)) return false;
13890 if (!at(iter, 2, 0)) return false;
13891 if (!at(iter, 2, 1)) return false;
13892 if (!at(iter, 2, 2)) return false;
13893 if (!at(iter, 2, 3)) return false;
13894 if (!at(iter, 2, 4)) return false;
13895 if (!at(iter, 3, 0)) return false;
13896 if (!at(iter, 3, 1)) return false;
13897 if (!at(iter, 3, 2)) return false;
13898 if (!at(iter, 3, 3)) return false;
13899 if (!at(iter, 3, 4)) return false;
13900 if (!at(iter, 4, 0)) return false;
13901 if (!at(iter, 4, 1)) return false;
13902 if (!at(iter, 4, 2)) return false;
13903 if (!at(iter, 4, 3)) return false;
13904 if (!at(iter, 4, 4)) return false;
13905 return true;
13906 }
13907
13908 template<typename iterator_type_, typename function_type_>
13909 LITE_INLINE
13910 typename detail::enable_if<(
13911 detail::g_iterator_policy<iterator_type_>::use_index
13912 ), bool>::type
13913 for_each_c(
13914 const iterator_type_& iter,
13915 function_type_& func,
13916 const pack<constant<int, 5>, constant<int, 5> >&)
13917 {
13918 if (!func(at(iter, 0, 0))) return false;
13919 if (!func(at(iter, 0, 1))) return false;
13920 if (!func(at(iter, 0, 2))) return false;
13921 if (!func(at(iter, 0, 3))) return false;
13922 if (!func(at(iter, 0, 4))) return false;
13923 if (!func(at(iter, 1, 0))) return false;
13924 if (!func(at(iter, 1, 1))) return false;
13925 if (!func(at(iter, 1, 2))) return false;
13926 if (!func(at(iter, 1, 3))) return false;
13927 if (!func(at(iter, 1, 4))) return false;
13928 if (!func(at(iter, 2, 0))) return false;
13929 if (!func(at(iter, 2, 1))) return false;
13930 if (!func(at(iter, 2, 2))) return false;
13931 if (!func(at(iter, 2, 3))) return false;
13932 if (!func(at(iter, 2, 4))) return false;
13933 if (!func(at(iter, 3, 0))) return false;
13934 if (!func(at(iter, 3, 1))) return false;
13935 if (!func(at(iter, 3, 2))) return false;
13936 if (!func(at(iter, 3, 3))) return false;
13937 if (!func(at(iter, 3, 4))) return false;
13938 if (!func(at(iter, 4, 0))) return false;
13939 if (!func(at(iter, 4, 1))) return false;
13940 if (!func(at(iter, 4, 2))) return false;
13941 if (!func(at(iter, 4, 3))) return false;
13942 if (!func(at(iter, 4, 4))) return false;
13943 return true;
13944 }
13945
13946
13947
13948
13949
13950 template<typename iterator_type_, typename size_type_>
13951 LITE_INLINE
13952 typename detail::enable_if<(
13953 size_type_::n > 1
13954 )>::type
13955 for_each(const iterator_type_& iter, const size_type_& size)
13956 {
13957 typedef size_transformer<plane<0>, size_type_> s_transformer;
13958 typedef iterator_transformer<plane<0>, iterator_type_, size_type_> i_transformer;
13959
13960 iterator_type_ it = iter;
13961 typename s_transformer::size_type new_size;
13962 typename i_transformer::iterator_type new_it;
13963 const int n = size.i0;
13964
13965 s_transformer::transform(size, new_size);
13966
13967 for (int i=0; i<n; i++) {
13968 i_transformer::transform(it, new_it);
13969 for_each(new_it, new_size);
13970 inc<0>(it);
13971 }
13972 }
13973
13974 template<typename iterator_type_, typename function_type_, typename size_type_>
13975 LITE_INLINE
13976 typename detail::enable_if<(
13977 size_type_::n > 1
13978 )>::type
13979 for_each(const iterator_type_& iter, function_type_& func, const size_type_& size)
13980 {
13981 typedef size_transformer<plane<0>, size_type_> s_transformer;
13982 typedef iterator_transformer<plane<0>, iterator_type_, size_type_> i_transformer;
13983
13984 iterator_type_ it = iter;
13985 typename s_transformer::size_type new_size;
13986 typename i_transformer::iterator_type new_it;
13987 const int n = size.i0;
13988
13989 s_transformer::transform(size, new_size);
13990
13991 for (int i=0; i<n; i++) {
13992 i_transformer::transform(it, new_it);
13993 for_each(new_it, func, new_size);
13994 inc<0>(it);
13995 }
13996 }
13997
13998 template<typename iterator_type_, typename size_type_>
13999 LITE_INLINE
14000 typename detail::enable_if<(
14001 size_type_::n > 1
14002 ), bool>::type
14003 for_each_c(const iterator_type_& iter, const size_type_& size)
14004 {
14005 typedef size_transformer<plane<0>, size_type_> s_transformer;
14006 typedef iterator_transformer<plane<0>, iterator_type_, size_type_> i_transformer;
14007
14008 iterator_type_ it = iter;
14009 typename s_transformer::size_type new_size;
14010 typename i_transformer::iterator_type new_it;
14011 const int n = size.i0;
14012
14013 s_transformer::transform(size, new_size);
14014
14015 for (int i=0; i<n; i++) {
14016 i_transformer::transform(it, new_it);
14017 if (!for_each_c(new_it, new_size))
14018 return false;
14019 inc<0>(it);
14020 }
14021 return true;
14022 }
14023
14024
14025 template<typename iterator_type_, typename function_type_, typename size_type_>
14026 LITE_INLINE
14027 typename detail::enable_if<(
14028 size_type_::n > 1
14029 ), bool>::type
14030 for_each_c(const iterator_type_& iter, function_type_& func, const size_type_& size)
14031 {
14032 typedef size_transformer<plane<0>, size_type_> s_transformer;
14033 typedef iterator_transformer<plane<0>, iterator_type_, size_type_> i_transformer;
14034
14035 iterator_type_ it = iter;
14036 typename s_transformer::size_type new_size;
14037 typename i_transformer::iterator_type new_it;
14038 const int n = size.i0;
14039
14040 s_transformer::transform(size, new_size);
14041
14042 for (int i=0; i<n; i++) {
14043 i_transformer::transform(it, new_it);
14044 if (!for_each_c(new_it, func, new_size))
14045 return false;
14046 inc<0>(it);
14047 }
14048 return true;
14049 }
14050
14051 #endif // !DOCUMENTATION_ONLY
14052
14053
14054
14055
14056
14062 template<typename signature_, typename traits_type_, typename rep_>
14063 LITE_INLINE void for_each(const array<signature_, traits_type_, rep_>& a)
14064 {
14065 for_each(a.begin(), a.size());
14066 }
14067
14073 template<typename signature_, typename traits_type_, typename rep_>
14074 LITE_INLINE void for_each(array<signature_, traits_type_, rep_>& a)
14075 {
14076 for_each(a.begin(), a.size());
14077 }
14078
14085 template<typename signature_, typename traits_type_, typename rep_, typename function_type_>
14086 LITE_INLINE void for_each(const array<signature_, traits_type_, rep_>& a, function_type_& func)
14087 {
14088 for_each(a.begin(), func, a.size());
14089 }
14090
14097 template<typename signature_, typename traits_type_, typename rep_, typename function_type_>
14098 LITE_INLINE void for_each(array<signature_, traits_type_, rep_>& a, function_type_& func)
14099 {
14100 for_each(a.begin(), func, a.size());
14101 }
14102
14110 template<typename signature_, typename traits_type_, typename rep_>
14111 LITE_INLINE bool for_each_c(const array<signature_, traits_type_, rep_>& a)
14112 {
14113 return for_each_c(a.begin(), a.size());
14114 }
14115
14123 template<typename signature_, typename traits_type_, typename rep_>
14124 LITE_INLINE bool for_each_c(array<signature_, traits_type_, rep_>& a)
14125 {
14126 return for_each_c(a.begin(), a.size());
14127 }
14128
14137 template<typename signature_, typename traits_type_, typename rep_, typename function_type_>
14138 LITE_INLINE bool for_each_c(const array<signature_, traits_type_, rep_>& a, function_type_& func)
14139 {
14140 return for_each_c(a.begin(), func, a.size());
14141 }
14142
14151 template<typename signature_, typename traits_type_, typename rep_, typename function_type_>
14152 LITE_INLINE bool for_each_c(array<signature_, traits_type_, rep_>& a, function_type_& func)
14153 {
14154 return for_each_c(a.begin(), func, a.size());
14155 }
14156
14157
14158
14159
14160
14167 struct default_array_traits
14168 {
14169 template<typename signature_>
14170 struct representation_type
14171 {
14172 typedef array_signature_traits<signature_> array_details;
14173
14174 typedef typename detail::type_if<
14175 (array_details::volume <= 4096 && array_details::is_fixed_size),
14176 internal_rep<false>,
14177 hybrid_rep<false, (array_details::volume <= 64 ? 64 : 1)>
14178 >::type type;
14179
14180 typedef typename detail::type_if<
14181 (array_details::volume <= 4096 && array_details::is_fixed_size),
14182 internal_rep<false>,
14183 hybrid_rep<false, (array_details::volume <= 4096 ? 4096 : 1)>
14184 >::type temporary_type;
14185
14186 typedef typename detail::type_if<
14187 (array_details::volume <= 4096 && array_details::is_fixed_size),
14188 internal_rep<false>,
14189 hybrid_rep<false, (array_details::volume <= 4096 ? 4096 : 1)>
14190 >::type fwd_temporary_type;
14191
14192 typedef typename detail::type_if<
14193 (array_details::volume <= 4096 && array_details::is_fixed_size),
14194 internal_rep<true>,
14195 hybrid_rep<true, (array_details::volume <= 4096 ? 4096 : 1)>
14196 >::type rev_temporary_type;
14197 };
14198 };
14199
14200
14201
14202
14203
14204 template<typename signature_, typename traits_type_, typename src_rep_>
14205 LITE_INLINE
14206 typename array<signature_, traits_type_, src_rep_>::temporary_array
14207 copy(const array<signature_, traits_type_, src_rep_>& src)
14208 {
14209 return src;
14210 }
14211
14212
14213
14214
14215
14216 #ifdef DOCUMENTATION_ONLY
14217
14235 template<typename size_type_>
14236 int volume(const size_type_& sz);
14237
14238 #else // DOCUMENTATION_ONLY
14239
14240 LITE_INLINE int volume(const pack<>&)
14241 {
14242 return 1;
14243 }
14244
14245 template<
14246 typename type0_
14247 >
14248 LITE_INLINE int
14249 volume(
14250 const pack<
14251 type0_
14252 >& size)
14253 {
14254 return size.i0;
14255 LITE_ARRAY_USE(size);
14256 }
14257
14258 template<
14259 typename type0_,
14260 typename type1_
14261 >
14262 LITE_INLINE int
14263 volume(
14264 const pack<
14265 type0_,
14266 type1_
14267 >& size)
14268 {
14269 return size.i0*size.i1;
14270 LITE_ARRAY_USE(size);
14271 }
14272
14273 template<
14274 typename type0_,
14275 typename type1_,
14276 typename type2_
14277 >
14278 LITE_INLINE int
14279 volume(
14280 const pack<
14281 type0_,
14282 type1_,
14283 type2_
14284 >& size)
14285 {
14286 return size.i0*size.i1*size.i2;
14287 LITE_ARRAY_USE(size);
14288 }
14289
14290
14291
14292 #endif // DOCUMENTATION_ONLY
14293
14294
14295
14296
14297
14298
14299 template<typename type_>
14300 class assign;
14301
14302
14303 template<typename type_>
14304 class swapper;
14305
14306 #ifdef DOCUMENTATION_ONLY
14307
14318 template<
14319 typename signature_,
14320 typename traits_type_ = default_array_traits,
14321 typename rep_ = typename traits_type_::template representation_type<signature_>::type>
14322 class array
14323 {
14324 public:
14325 typedef signature_ signature;
14326 typedef traits_type_ traits_type;
14327 typedef ... value_type;
14328 typedef ... iterator;
14329 typedef ... const_iterator;
14330 typedef ... reference;
14331 typedef ... const_reference;
14332
14333
14339 typedef ... temporary_array;
14340
14346 typedef ... fwd_temporary_array;
14347
14353 typedef ... rev_temporary_array;
14354
14356 typedef ... size_type;
14357
14359 static const int dimensions = ...;
14360
14365 static const bool is_reverse = ...;
14366
14375 array();
14376
14381 array(const array& other);
14382
14393 template<typename other_rep_>
14394 array(const array<signature_, traits_type_, other_rep_>& other);
14395
14404 explicit array(int n0, ..., int nN);
14405
14412 explicit array(const size_type& size);
14413
14430 array(const value_type& a0, ..., const value_type& aT);
14431
14444 template<typename arg_type0_, ..., typename arg_typeK_>
14445 array(const arg_type0_& arg0, ..., const arg_typeK_& argK, const size_type& sz);
14446
14457 template<typename other_iterator_type_, typename other_size_type_, typename transform_type_>
14458 array(
14459 const other_iterator_type_& it,
14460 const other_size_type_& sz,
14461 const transform_type_& trans);
14462
14463
14471 array& operator=(const array& other);
14472
14482 template<typename other_rep_>
14483 array& operator=(const array<signature_, traits_type_, other_rep_>& other);
14484
14486 const_iterator begin() const;
14487
14489 iterator begin();
14490
14492 size_type size() const;
14493
14495 const_reference operator()(int i0, ..., int iN) const;
14496
14498 reference operator()(int i0, ..., int iN);
14499
14505 const_reference operator[](int i0) const;
14506
14512 reference operator[](int i0);
14513
14521 template<typename transform_type_>
14522 const typename transform_traits<array, transform_type_>::const_array
14523 operator[](const transform_type_& trans) const;
14524
14532 template<typename transform_type_>
14533 const typename transform_traits<array, transform_type_>::array
14534 operator[](const transform_type_& trans);
14535
14545 const value_type* data() const;
14546
14556 value_type* data();
14557
14573 void resize(int n0, ..., int nN);
14574
14588 void resize(const size_type& sz);
14589
14598 void release();
14599 };
14600
14601 #endif // DOCUMENTATION_ONLY
14602
14603
14604
14605
14606
14614 template<typename iterator_type_>
14615 class reference_rep {};
14616
14617
14618 template<
14619 typename value_type_,
14620 typename traits_type_,
14621 typename iterator_
14622 >
14623 class array<
14624 value_type_,
14625 traits_type_,
14626 reference_rep<iterator_>
14627 >
14628 {
14629 public:
14630 typedef value_type_ signature;
14631 typedef traits_type_ traits_type;
14632 typedef value_type_ value_type;
14633 typedef iterator_ iterator;
14634 typedef iterator_ const_iterator;
14635 typedef typename std::iterator_traits<iterator>::reference reference;
14636 typedef reference const_reference;
14637
14638 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
14639 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
14640 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
14641
14642 typedef typename array_signature_traits<signature>::size_type size_type;
14643
14644 static const int dimensions = 0;
14645
14646 LITE_INLINE array(const array& other)
14647 : m_iterator(other.m_iterator), m_size(other.m_size)
14648 {}
14649
14650 template<typename other_rep_>
14651 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
14652 : m_iterator(other.begin()), m_size(other.size())
14653 {}
14654
14655 template<typename other_rep_>
14656 LITE_INLINE array(array<signature, traits_type_, other_rep_>& other)
14657 : m_iterator(other.begin()), m_size(other.size())
14658 {}
14659
14660 template<
14661 typename arg_type0_
14662 >
14663 LITE_INLINE array(
14664 const arg_type0_& arg0,
14665 const size_type& sz)
14666 : m_iterator(arg0),
14667 m_size(sz)
14668 {}
14669
14670 template<
14671 typename arg_type0_,
14672 typename arg_type1_
14673 >
14674 LITE_INLINE array(
14675 const arg_type0_& arg0,
14676 const arg_type1_& arg1,
14677 const size_type& sz)
14678 : m_iterator(arg0, arg1),
14679 m_size(sz)
14680 {}
14681
14682 template<
14683 typename arg_type0_,
14684 typename arg_type1_,
14685 typename arg_type2_
14686 >
14687 LITE_INLINE array(
14688 const arg_type0_& arg0,
14689 const arg_type1_& arg1,
14690 const arg_type2_& arg2,
14691 const size_type& sz)
14692 : m_iterator(arg0, arg1, arg2),
14693 m_size(sz)
14694 {}
14695
14696
14697 template<typename other_iterator_type_, typename other_size_type_, typename transform_type_>
14698 LITE_INLINE array(
14699 const other_iterator_type_& it,
14700 const other_size_type_& sz,
14701 const transform_type_& trans)
14702 {
14703 iterator_transformer<transform_type_, other_iterator_type_, other_size_type_>
14704 ::transform(trans, it, sz, m_iterator);
14705
14706 size_transformer<transform_type_, other_size_type_>
14707 ::transform(trans, sz, m_size);
14708 }
14709
14710 LITE_INLINE const array& operator=(const array& other) const
14711 {
14712 typedef b_iterator<iterator, iterator, assign<value_type> > iterator_type;
14713
14714 LITE_ARRAY_SIZE_CHECK(m_size, other.m_size, "operator=(): array sizes do not match");
14715
14716 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
14717 return *this;
14718 }
14719
14720 template<typename other_rep_>
14721 LITE_INLINE const array& operator=(const array<signature, traits_type_, other_rep_>& other) const
14722 {
14723 typedef b_iterator<
14724 iterator,
14725 typename array<signature, traits_type_, other_rep_>::const_iterator,
14726 assign<value_type> >
14727 iterator_type;
14728
14729 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "operator=(): array sizes do not match");
14730
14731 for_each(iterator_type(m_iterator, other.begin()), m_size);
14732 return *this;
14733 }
14734
14735 LITE_INLINE const array& operator=(const value_type& value) const
14736 {
14737 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
14738
14739 for_each(iterator_type(m_iterator, value), m_size);
14740 return *this;
14741 }
14742
14743 LITE_INLINE const iterator& begin() const
14744 {
14745 return m_iterator;
14746 }
14747
14748 LITE_INLINE const size_type& size() const
14749 {
14750 return m_size;
14751 }
14752
14753 LITE_INLINE reference
14754 operator()() const
14755 {
14756 return at(m_iterator);
14757 }
14758
14759 template<typename transform_type_>
14760 LITE_INLINE const typename transform_traits<array, transform_type_>::array
14761 operator[](const transform_type_& trans) const
14762 {
14763 typedef typename transform_traits<array, transform_type_>::array result_type;
14764
14765 return result_type(m_iterator, m_size, trans);
14766 }
14767
14768 template<typename other_rep_>
14769 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other) const
14770 {
14771 typedef b_iterator<
14772 iterator,
14773 typename array<signature, traits_type_, other_rep_>::const_iterator,
14774 swapper<value_type> >
14775 iterator_type;
14776
14777 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "swap(): array sizes do not match");
14778
14779 for_each(iterator_type(m_iterator, other.begin()), m_size);
14780 }
14781
14782 template<typename other_rep_>
14783 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other) const
14784 {
14785 typedef b_iterator<
14786 iterator,
14787 typename array<signature, traits_type_, other_rep_>::iterator,
14788 swapper<value_type> >
14789 iterator_type;
14790
14791 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "swap(): array sizes do not match");
14792
14793 for_each(iterator_type(m_iterator, other.begin()), m_size);
14794 }
14795
14796 private:
14797 iterator m_iterator;
14798 size_type m_size;
14799 };
14800
14801
14802
14803 template<
14804 typename value_type_,
14805 int n0_,
14806 typename traits_type_,
14807 typename iterator_
14808 >
14809 class array<
14810 value_type_[n0_],
14811 traits_type_,
14812 reference_rep<iterator_>
14813 >
14814 {
14815 public:
14816 typedef value_type_ signature[n0_];
14817 typedef traits_type_ traits_type;
14818 typedef value_type_ value_type;
14819 typedef iterator_ iterator;
14820 typedef iterator_ const_iterator;
14821 typedef typename std::iterator_traits<iterator>::reference reference;
14822 typedef reference const_reference;
14823
14824 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
14825 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
14826 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
14827
14828 typedef typename array_signature_traits<signature>::size_type size_type;
14829
14830 static const int dimensions = 1;
14831
14832 LITE_INLINE array(const array& other)
14833 : m_iterator(other.m_iterator), m_size(other.m_size)
14834 {}
14835
14836 template<typename other_rep_>
14837 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
14838 : m_iterator(other.begin()), m_size(other.size())
14839 {}
14840
14841 template<typename other_rep_>
14842 LITE_INLINE array(array<signature, traits_type_, other_rep_>& other)
14843 : m_iterator(other.begin()), m_size(other.size())
14844 {}
14845
14846 template<
14847 typename arg_type0_
14848 >
14849 LITE_INLINE array(
14850 const arg_type0_& arg0,
14851 const size_type& sz)
14852 : m_iterator(arg0),
14853 m_size(sz)
14854 {}
14855
14856 template<
14857 typename arg_type0_,
14858 typename arg_type1_
14859 >
14860 LITE_INLINE array(
14861 const arg_type0_& arg0,
14862 const arg_type1_& arg1,
14863 const size_type& sz)
14864 : m_iterator(arg0, arg1),
14865 m_size(sz)
14866 {}
14867
14868 template<
14869 typename arg_type0_,
14870 typename arg_type1_,
14871 typename arg_type2_
14872 >
14873 LITE_INLINE array(
14874 const arg_type0_& arg0,
14875 const arg_type1_& arg1,
14876 const arg_type2_& arg2,
14877 const size_type& sz)
14878 : m_iterator(arg0, arg1, arg2),
14879 m_size(sz)
14880 {}
14881
14882
14883 template<typename other_iterator_type_, typename other_size_type_, typename transform_type_>
14884 LITE_INLINE array(
14885 const other_iterator_type_& it,
14886 const other_size_type_& sz,
14887 const transform_type_& trans)
14888 {
14889 iterator_transformer<transform_type_, other_iterator_type_, other_size_type_>
14890 ::transform(trans, it, sz, m_iterator);
14891
14892 size_transformer<transform_type_, other_size_type_>
14893 ::transform(trans, sz, m_size);
14894 }
14895
14896 LITE_INLINE const array& operator=(const array& other) const
14897 {
14898 typedef b_iterator<iterator, iterator, assign<value_type> > iterator_type;
14899
14900 LITE_ARRAY_SIZE_CHECK(m_size, other.m_size, "operator=(): array sizes do not match");
14901
14902 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
14903 return *this;
14904 }
14905
14906 template<typename other_rep_>
14907 LITE_INLINE const array& operator=(const array<signature, traits_type_, other_rep_>& other) const
14908 {
14909 typedef b_iterator<
14910 iterator,
14911 typename array<signature, traits_type_, other_rep_>::const_iterator,
14912 assign<value_type> >
14913 iterator_type;
14914
14915 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "operator=(): array sizes do not match");
14916
14917 for_each(iterator_type(m_iterator, other.begin()), m_size);
14918 return *this;
14919 }
14920
14921 LITE_INLINE const array& operator=(const value_type& value) const
14922 {
14923 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
14924
14925 for_each(iterator_type(m_iterator, value), m_size);
14926 return *this;
14927 }
14928
14929 LITE_INLINE const iterator& begin() const
14930 {
14931 return m_iterator;
14932 }
14933
14934 LITE_INLINE const size_type& size() const
14935 {
14936 return m_size;
14937 }
14938
14939 LITE_INLINE reference
14940 operator()(int i0) const
14941 {
14942 return at(m_iterator, i0);
14943 }
14944
14945 LITE_INLINE reference
14946 operator[](int i0) const
14947 {
14948 return at(m_iterator, i0);
14949 }
14950
14951 template<typename transform_type_>
14952 LITE_INLINE const typename transform_traits<array, transform_type_>::array
14953 operator[](const transform_type_& trans) const
14954 {
14955 typedef typename transform_traits<array, transform_type_>::array result_type;
14956
14957 return result_type(m_iterator, m_size, trans);
14958 }
14959
14960 template<typename other_rep_>
14961 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other) const
14962 {
14963 typedef b_iterator<
14964 iterator,
14965 typename array<signature, traits_type_, other_rep_>::const_iterator,
14966 swapper<value_type> >
14967 iterator_type;
14968
14969 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "swap(): array sizes do not match");
14970
14971 for_each(iterator_type(m_iterator, other.begin()), m_size);
14972 }
14973
14974 template<typename other_rep_>
14975 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other) const
14976 {
14977 typedef b_iterator<
14978 iterator,
14979 typename array<signature, traits_type_, other_rep_>::iterator,
14980 swapper<value_type> >
14981 iterator_type;
14982
14983 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "swap(): array sizes do not match");
14984
14985 for_each(iterator_type(m_iterator, other.begin()), m_size);
14986 }
14987
14988 private:
14989 iterator m_iterator;
14990 size_type m_size;
14991 };
14992
14993
14994
14995 template<
14996 typename value_type_,
14997 int n0_,
14998 int n1_,
14999 typename traits_type_,
15000 typename iterator_
15001 >
15002 class array<
15003 value_type_[n0_][n1_],
15004 traits_type_,
15005 reference_rep<iterator_>
15006 >
15007 {
15008 public:
15009 typedef value_type_ signature[n0_][n1_];
15010 typedef traits_type_ traits_type;
15011 typedef value_type_ value_type;
15012 typedef iterator_ iterator;
15013 typedef iterator_ const_iterator;
15014 typedef typename std::iterator_traits<iterator>::reference reference;
15015 typedef reference const_reference;
15016
15017 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
15018 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
15019 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
15020
15021 typedef typename array_signature_traits<signature>::size_type size_type;
15022
15023 static const int dimensions = 2;
15024
15025 LITE_INLINE array(const array& other)
15026 : m_iterator(other.m_iterator), m_size(other.m_size)
15027 {}
15028
15029 template<typename other_rep_>
15030 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
15031 : m_iterator(other.begin()), m_size(other.size())
15032 {}
15033
15034 template<typename other_rep_>
15035 LITE_INLINE array(array<signature, traits_type_, other_rep_>& other)
15036 : m_iterator(other.begin()), m_size(other.size())
15037 {}
15038
15039 template<
15040 typename arg_type0_
15041 >
15042 LITE_INLINE array(
15043 const arg_type0_& arg0,
15044 const size_type& sz)
15045 : m_iterator(arg0),
15046 m_size(sz)
15047 {}
15048
15049 template<
15050 typename arg_type0_,
15051 typename arg_type1_
15052 >
15053 LITE_INLINE array(
15054 const arg_type0_& arg0,
15055 const arg_type1_& arg1,
15056 const size_type& sz)
15057 : m_iterator(arg0, arg1),
15058 m_size(sz)
15059 {}
15060
15061 template<
15062 typename arg_type0_,
15063 typename arg_type1_,
15064 typename arg_type2_
15065 >
15066 LITE_INLINE array(
15067 const arg_type0_& arg0,
15068 const arg_type1_& arg1,
15069 const arg_type2_& arg2,
15070 const size_type& sz)
15071 : m_iterator(arg0, arg1, arg2),
15072 m_size(sz)
15073 {}
15074
15075
15076 template<typename other_iterator_type_, typename other_size_type_, typename transform_type_>
15077 LITE_INLINE array(
15078 const other_iterator_type_& it,
15079 const other_size_type_& sz,
15080 const transform_type_& trans)
15081 {
15082 iterator_transformer<transform_type_, other_iterator_type_, other_size_type_>
15083 ::transform(trans, it, sz, m_iterator);
15084
15085 size_transformer<transform_type_, other_size_type_>
15086 ::transform(trans, sz, m_size);
15087 }
15088
15089 LITE_INLINE const array& operator=(const array& other) const
15090 {
15091 typedef b_iterator<iterator, iterator, assign<value_type> > iterator_type;
15092
15093 LITE_ARRAY_SIZE_CHECK(m_size, other.m_size, "operator=(): array sizes do not match");
15094
15095 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
15096 return *this;
15097 }
15098
15099 template<typename other_rep_>
15100 LITE_INLINE const array& operator=(const array<signature, traits_type_, other_rep_>& other) const
15101 {
15102 typedef b_iterator<
15103 iterator,
15104 typename array<signature, traits_type_, other_rep_>::const_iterator,
15105 assign<value_type> >
15106 iterator_type;
15107
15108 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "operator=(): array sizes do not match");
15109
15110 for_each(iterator_type(m_iterator, other.begin()), m_size);
15111 return *this;
15112 }
15113
15114 LITE_INLINE const array& operator=(const value_type& value) const
15115 {
15116 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
15117
15118 for_each(iterator_type(m_iterator, value), m_size);
15119 return *this;
15120 }
15121
15122 LITE_INLINE const iterator& begin() const
15123 {
15124 return m_iterator;
15125 }
15126
15127 LITE_INLINE const size_type& size() const
15128 {
15129 return m_size;
15130 }
15131
15132 LITE_INLINE reference
15133 operator()(int i0, int i1) const
15134 {
15135 return at(m_iterator, i0, i1);
15136 }
15137
15138 template<typename transform_type_>
15139 LITE_INLINE const typename transform_traits<array, transform_type_>::array
15140 operator[](const transform_type_& trans) const
15141 {
15142 typedef typename transform_traits<array, transform_type_>::array result_type;
15143
15144 return result_type(m_iterator, m_size, trans);
15145 }
15146
15147 template<typename other_rep_>
15148 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other) const
15149 {
15150 typedef b_iterator<
15151 iterator,
15152 typename array<signature, traits_type_, other_rep_>::const_iterator,
15153 swapper<value_type> >
15154 iterator_type;
15155
15156 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "swap(): array sizes do not match");
15157
15158 for_each(iterator_type(m_iterator, other.begin()), m_size);
15159 }
15160
15161 template<typename other_rep_>
15162 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other) const
15163 {
15164 typedef b_iterator<
15165 iterator,
15166 typename array<signature, traits_type_, other_rep_>::iterator,
15167 swapper<value_type> >
15168 iterator_type;
15169
15170 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "swap(): array sizes do not match");
15171
15172 for_each(iterator_type(m_iterator, other.begin()), m_size);
15173 }
15174
15175 private:
15176 iterator m_iterator;
15177 size_type m_size;
15178 };
15179
15180
15181
15182 template<
15183 typename value_type_,
15184 int n0_,
15185 int n1_,
15186 int n2_,
15187 typename traits_type_,
15188 typename iterator_
15189 >
15190 class array<
15191 value_type_[n0_][n1_][n2_],
15192 traits_type_,
15193 reference_rep<iterator_>
15194 >
15195 {
15196 public:
15197 typedef value_type_ signature[n0_][n1_][n2_];
15198 typedef traits_type_ traits_type;
15199 typedef value_type_ value_type;
15200 typedef iterator_ iterator;
15201 typedef iterator_ const_iterator;
15202 typedef typename std::iterator_traits<iterator>::reference reference;
15203 typedef reference const_reference;
15204
15205 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
15206 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
15207 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
15208
15209 typedef typename array_signature_traits<signature>::size_type size_type;
15210
15211 static const int dimensions = 3;
15212
15213 LITE_INLINE array(const array& other)
15214 : m_iterator(other.m_iterator), m_size(other.m_size)
15215 {}
15216
15217 template<typename other_rep_>
15218 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
15219 : m_iterator(other.begin()), m_size(other.size())
15220 {}
15221
15222 template<typename other_rep_>
15223 LITE_INLINE array(array<signature, traits_type_, other_rep_>& other)
15224 : m_iterator(other.begin()), m_size(other.size())
15225 {}
15226
15227 template<
15228 typename arg_type0_
15229 >
15230 LITE_INLINE array(
15231 const arg_type0_& arg0,
15232 const size_type& sz)
15233 : m_iterator(arg0),
15234 m_size(sz)
15235 {}
15236
15237 template<
15238 typename arg_type0_,
15239 typename arg_type1_
15240 >
15241 LITE_INLINE array(
15242 const arg_type0_& arg0,
15243 const arg_type1_& arg1,
15244 const size_type& sz)
15245 : m_iterator(arg0, arg1),
15246 m_size(sz)
15247 {}
15248
15249 template<
15250 typename arg_type0_,
15251 typename arg_type1_,
15252 typename arg_type2_
15253 >
15254 LITE_INLINE array(
15255 const arg_type0_& arg0,
15256 const arg_type1_& arg1,
15257 const arg_type2_& arg2,
15258 const size_type& sz)
15259 : m_iterator(arg0, arg1, arg2),
15260 m_size(sz)
15261 {}
15262
15263
15264 template<typename other_iterator_type_, typename other_size_type_, typename transform_type_>
15265 LITE_INLINE array(
15266 const other_iterator_type_& it,
15267 const other_size_type_& sz,
15268 const transform_type_& trans)
15269 {
15270 iterator_transformer<transform_type_, other_iterator_type_, other_size_type_>
15271 ::transform(trans, it, sz, m_iterator);
15272
15273 size_transformer<transform_type_, other_size_type_>
15274 ::transform(trans, sz, m_size);
15275 }
15276
15277 LITE_INLINE const array& operator=(const array& other) const
15278 {
15279 typedef b_iterator<iterator, iterator, assign<value_type> > iterator_type;
15280
15281 LITE_ARRAY_SIZE_CHECK(m_size, other.m_size, "operator=(): array sizes do not match");
15282
15283 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
15284 return *this;
15285 }
15286
15287 template<typename other_rep_>
15288 LITE_INLINE const array& operator=(const array<signature, traits_type_, other_rep_>& other) const
15289 {
15290 typedef b_iterator<
15291 iterator,
15292 typename array<signature, traits_type_, other_rep_>::const_iterator,
15293 assign<value_type> >
15294 iterator_type;
15295
15296 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "operator=(): array sizes do not match");
15297
15298 for_each(iterator_type(m_iterator, other.begin()), m_size);
15299 return *this;
15300 }
15301
15302 LITE_INLINE const array& operator=(const value_type& value) const
15303 {
15304 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
15305
15306 for_each(iterator_type(m_iterator, value), m_size);
15307 return *this;
15308 }
15309
15310 LITE_INLINE const iterator& begin() const
15311 {
15312 return m_iterator;
15313 }
15314
15315 LITE_INLINE const size_type& size() const
15316 {
15317 return m_size;
15318 }
15319
15320 LITE_INLINE reference
15321 operator()(int i0, int i1, int i2) const
15322 {
15323 return at(m_iterator, i0, i1, i2);
15324 }
15325
15326 template<typename transform_type_>
15327 LITE_INLINE const typename transform_traits<array, transform_type_>::array
15328 operator[](const transform_type_& trans) const
15329 {
15330 typedef typename transform_traits<array, transform_type_>::array result_type;
15331
15332 return result_type(m_iterator, m_size, trans);
15333 }
15334
15335 template<typename other_rep_>
15336 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other) const
15337 {
15338 typedef b_iterator<
15339 iterator,
15340 typename array<signature, traits_type_, other_rep_>::const_iterator,
15341 swapper<value_type> >
15342 iterator_type;
15343
15344 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "swap(): array sizes do not match");
15345
15346 for_each(iterator_type(m_iterator, other.begin()), m_size);
15347 }
15348
15349 template<typename other_rep_>
15350 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other) const
15351 {
15352 typedef b_iterator<
15353 iterator,
15354 typename array<signature, traits_type_, other_rep_>::iterator,
15355 swapper<value_type> >
15356 iterator_type;
15357
15358 LITE_ARRAY_SIZE_CHECK(m_size, other.size(), "swap(): array sizes do not match");
15359
15360 for_each(iterator_type(m_iterator, other.begin()), m_size);
15361 }
15362
15363 private:
15364 iterator m_iterator;
15365 size_type m_size;
15366 };
15367
15368
15369
15370
15371
15372
15373
15374
15382 template<bool reversed_>
15383 class internal_rep {};
15384
15385
15386 template<typename type_>
15387 class swapper;
15388
15389 template<
15390 typename value_type_,
15391 typename traits_type_
15392 >
15393 class array<
15394 value_type_,
15395 traits_type_,
15396 internal_rep<false>
15397 >
15398 {
15399 public:
15400 typedef value_type_ signature;
15401 typedef traits_type_ traits_type;
15402 typedef value_type_ value_type;
15403 typedef const value_type_& const_reference;
15404 typedef value_type_& reference;
15405
15406 typedef typename array_signature_traits<const signature>::default_iterator const_iterator;
15407 typedef typename array_signature_traits<signature>::default_iterator iterator;
15408 typedef typename array_signature_traits<signature>::size_type size_type;
15409
15410 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
15411 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
15412 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
15413
15414 static const bool is_reverse = false;
15415 static const int dimensions = 0;
15416
15417 LITE_INLINE array()
15418 {}
15419
15420
15421 explicit LITE_INLINE array(const size_type&)
15422 {}
15423
15424 LITE_INLINE array(const array& other)
15425 {
15426 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
15427
15428 for_each(iterator_type(
15429 &m_data,
15430 &other.m_data),
15431 size_type());
15432 }
15433
15434 template<typename other_rep_>
15435 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
15436 {
15437 typedef b_iterator<
15438 iterator,
15439 typename array<signature, traits_type_, other_rep_>::const_iterator,
15440 assign<value_type> >
15441 iterator_type;
15442
15443 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
15444
15445 for_each(iterator_type(&m_data, other.begin()), size_type());
15446 }
15447
15448 LITE_INLINE array(const value_type& value)
15449 {
15450 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
15451
15452 for_each(iterator_type(&m_data, value), size_type());
15453 }
15454
15455
15456 LITE_INLINE array& operator=(const array& other)
15457 {
15458 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
15459
15460 for_each(iterator_type(
15461 &m_data,
15462 &other.m_data),
15463 size_type());
15464 return *this;
15465 }
15466
15467 template<typename other_rep_>
15468 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
15469 {
15470 typedef b_iterator<
15471 iterator,
15472 typename array<signature, traits_type_, other_rep_>::const_iterator,
15473 assign<value_type> >
15474 iterator_type;
15475
15476 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
15477
15478 for_each(iterator_type(&m_data, other.begin()), size_type());
15479 return *this;
15480 }
15481
15482 LITE_INLINE array& operator=(const value_type& value)
15483 {
15484 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
15485
15486 for_each(iterator_type(&m_data, value), size_type());
15487 return *this;
15488 }
15489
15490 LITE_INLINE const_iterator begin() const
15491 {
15492 return const_iterator(&m_data);
15493 }
15494
15495 LITE_INLINE iterator begin()
15496 {
15497 return iterator(&m_data);
15498 }
15499
15500 LITE_INLINE size_type size() const
15501 {
15502 return size_type();
15503 }
15504
15505 LITE_INLINE const_reference
15506 operator()() const
15507 {
15508 return m_data;
15509 }
15510
15511 LITE_INLINE reference
15512 operator()()
15513 {
15514 return m_data;
15515 }
15516
15517
15518 template<typename transform_type_>
15519 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
15520 operator[](const transform_type_& trans) const
15521 {
15522 typedef typename transform_traits<array, transform_type_>::const_array result_type;
15523
15524 return result_type(begin(), size(), trans);
15525 }
15526
15527 template<typename transform_type_>
15528 LITE_INLINE const typename transform_traits<array, transform_type_>::array
15529 operator[](const transform_type_& trans)
15530 {
15531 typedef typename transform_traits<array, transform_type_>::array result_type;
15532
15533 return result_type(begin(), size(), trans);
15534 }
15535
15536 LITE_INLINE const value_type* data() const
15537 {
15538 return &m_data;
15539 }
15540
15541 LITE_INLINE value_type* data()
15542 {
15543 return &m_data;
15544 }
15545
15546 LITE_INLINE void release()
15547 {}
15548
15549 LITE_INLINE void resize()
15550 {}
15551
15552 LITE_INLINE void resize(const size_type&)
15553 {}
15554
15555 template<typename other_rep_>
15556 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
15557 {
15558 typedef b_iterator<
15559 iterator,
15560 typename array<signature, traits_type_, other_rep_>::const_iterator,
15561 swapper<value_type> >
15562 iterator_type;
15563
15564 for_each(iterator_type(&m_data, other.begin()), size_type());
15565 }
15566
15567 template<typename other_rep_>
15568 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
15569 {
15570 typedef b_iterator<
15571 iterator,
15572 typename array<signature, traits_type_, other_rep_>::iterator,
15573 swapper<value_type> >
15574 iterator_type;
15575
15576 for_each(iterator_type(&m_data, other.begin()), size_type());
15577 }
15578
15579 private:
15580 value_type m_data;
15581 };
15582
15583
15584
15585 template<
15586 typename value_type_,
15587 int n0_,
15588 typename traits_type_
15589 >
15590 class array<
15591 value_type_[n0_],
15592 traits_type_,
15593 internal_rep<false>
15594 >
15595 {
15596 public:
15597 typedef value_type_ signature[n0_];
15598 typedef traits_type_ traits_type;
15599 typedef value_type_ value_type;
15600 typedef const value_type_& const_reference;
15601 typedef value_type_& reference;
15602
15603 typedef typename array_signature_traits<const signature>::default_iterator const_iterator;
15604 typedef typename array_signature_traits<signature>::default_iterator iterator;
15605 typedef typename array_signature_traits<signature>::size_type size_type;
15606
15607 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
15608 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
15609 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
15610
15611 static const bool is_reverse = false;
15612 static const int dimensions = 1;
15613
15614 LITE_INLINE array()
15615 {}
15616
15617 explicit LITE_INLINE array(int)
15618 {}
15619
15620 explicit LITE_INLINE array(const size_type&)
15621 {}
15622
15623 LITE_INLINE array(const array& other)
15624 {
15625 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
15626
15627 for_each(iterator_type(
15628 &m_data[0],
15629 &other.m_data[0]),
15630 size_type());
15631 }
15632
15633 template<typename other_rep_>
15634 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
15635 {
15636 typedef b_iterator<
15637 iterator,
15638 typename array<signature, traits_type_, other_rep_>::const_iterator,
15639 assign<value_type> >
15640 iterator_type;
15641
15642 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
15643
15644 for_each(iterator_type(&m_data[0], other.begin()), size_type());
15645 }
15646
15647 LITE_INLINE array(const value_type& value)
15648 {
15649 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
15650
15651 for_each(iterator_type(&m_data[0], value), size_type());
15652 }
15653
15654
15655 LITE_INLINE array(
15656 typename detail::type_if<n0_==2, const value_type&, detail::invalid_argument>::type a0,
15657 const value_type& a1
15658 )
15659 {
15660 m_data[0] = a0;
15661 m_data[1] = a1;
15662 }
15663
15664 LITE_INLINE array(
15665 typename detail::type_if<n0_==3, const value_type&, detail::invalid_argument>::type a0,
15666 const value_type& a1,
15667 const value_type& a2
15668 )
15669 {
15670 m_data[0] = a0;
15671 m_data[1] = a1;
15672 m_data[2] = a2;
15673 }
15674
15675 LITE_INLINE array(
15676 typename detail::type_if<n0_==4, const value_type&, detail::invalid_argument>::type a0,
15677 const value_type& a1,
15678 const value_type& a2,
15679 const value_type& a3
15680 )
15681 {
15682 m_data[0] = a0;
15683 m_data[1] = a1;
15684 m_data[2] = a2;
15685 m_data[3] = a3;
15686 }
15687
15688 LITE_INLINE array(
15689 typename detail::type_if<n0_==5, const value_type&, detail::invalid_argument>::type a0,
15690 const value_type& a1,
15691 const value_type& a2,
15692 const value_type& a3,
15693 const value_type& a4
15694 )
15695 {
15696 m_data[0] = a0;
15697 m_data[1] = a1;
15698 m_data[2] = a2;
15699 m_data[3] = a3;
15700 m_data[4] = a4;
15701 }
15702
15703 LITE_INLINE array& operator=(const array& other)
15704 {
15705 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
15706
15707 for_each(iterator_type(
15708 &m_data[0],
15709 &other.m_data[0]),
15710 size_type());
15711 return *this;
15712 }
15713
15714 template<typename other_rep_>
15715 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
15716 {
15717 typedef b_iterator<
15718 iterator,
15719 typename array<signature, traits_type_, other_rep_>::const_iterator,
15720 assign<value_type> >
15721 iterator_type;
15722
15723 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
15724
15725 for_each(iterator_type(&m_data[0], other.begin()), size_type());
15726 return *this;
15727 }
15728
15729 LITE_INLINE array& operator=(const value_type& value)
15730 {
15731 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
15732
15733 for_each(iterator_type(&m_data[0], value), size_type());
15734 return *this;
15735 }
15736
15737 LITE_INLINE const_iterator begin() const
15738 {
15739 return const_iterator(&m_data[0]);
15740 }
15741
15742 LITE_INLINE iterator begin()
15743 {
15744 return iterator(&m_data[0]);
15745 }
15746
15747 LITE_INLINE size_type size() const
15748 {
15749 return size_type();
15750 }
15751
15752 LITE_INLINE const_reference
15753 operator()(int i0) const
15754 {
15755 return m_data[i0];
15756 }
15757
15758 LITE_INLINE reference
15759 operator()(int i0)
15760 {
15761 return m_data[i0];
15762 }
15763
15764 LITE_INLINE const_reference
15765 operator[](int i0) const
15766 {
15767 return m_data[i0];
15768 }
15769
15770 LITE_INLINE reference
15771 operator[](int i0)
15772 {
15773 return m_data[i0];
15774 }
15775
15776
15777 template<typename transform_type_>
15778 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
15779 operator[](const transform_type_& trans) const
15780 {
15781 typedef typename transform_traits<array, transform_type_>::const_array result_type;
15782
15783 return result_type(begin(), size(), trans);
15784 }
15785
15786 template<typename transform_type_>
15787 LITE_INLINE const typename transform_traits<array, transform_type_>::array
15788 operator[](const transform_type_& trans)
15789 {
15790 typedef typename transform_traits<array, transform_type_>::array result_type;
15791
15792 return result_type(begin(), size(), trans);
15793 }
15794
15795 LITE_INLINE const value_type* data() const
15796 {
15797 return &m_data[0];
15798 }
15799
15800 LITE_INLINE value_type* data()
15801 {
15802 return &m_data[0];
15803 }
15804
15805 LITE_INLINE void release()
15806 {}
15807
15808 LITE_INLINE void resize(int)
15809 {}
15810
15811 LITE_INLINE void resize(const size_type&)
15812 {}
15813
15814 template<typename other_rep_>
15815 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
15816 {
15817 typedef b_iterator<
15818 iterator,
15819 typename array<signature, traits_type_, other_rep_>::const_iterator,
15820 swapper<value_type> >
15821 iterator_type;
15822
15823 for_each(iterator_type(&m_data[0], other.begin()), size_type());
15824 }
15825
15826 template<typename other_rep_>
15827 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
15828 {
15829 typedef b_iterator<
15830 iterator,
15831 typename array<signature, traits_type_, other_rep_>::iterator,
15832 swapper<value_type> >
15833 iterator_type;
15834
15835 for_each(iterator_type(&m_data[0], other.begin()), size_type());
15836 }
15837
15838 private:
15839 value_type m_data[n0_];
15840 };
15841
15842
15843
15844 template<
15845 typename value_type_,
15846 int n0_,
15847 int n1_,
15848 typename traits_type_
15849 >
15850 class array<
15851 value_type_[n0_][n1_],
15852 traits_type_,
15853 internal_rep<false>
15854 >
15855 {
15856 public:
15857 typedef value_type_ signature[n0_][n1_];
15858 typedef traits_type_ traits_type;
15859 typedef value_type_ value_type;
15860 typedef const value_type_& const_reference;
15861 typedef value_type_& reference;
15862
15863 typedef typename array_signature_traits<const signature>::default_iterator const_iterator;
15864 typedef typename array_signature_traits<signature>::default_iterator iterator;
15865 typedef typename array_signature_traits<signature>::size_type size_type;
15866
15867 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
15868 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
15869 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
15870
15871 static const bool is_reverse = false;
15872 static const int dimensions = 2;
15873
15874 LITE_INLINE array()
15875 {}
15876
15877 explicit LITE_INLINE array(int, int)
15878 {}
15879
15880 explicit LITE_INLINE array(const size_type&)
15881 {}
15882
15883 LITE_INLINE array(const array& other)
15884 {
15885 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
15886
15887 for_each(iterator_type(
15888 &m_data[0][0],
15889 &other.m_data[0][0]),
15890 size_type());
15891 }
15892
15893 template<typename other_rep_>
15894 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
15895 {
15896 typedef b_iterator<
15897 iterator,
15898 typename array<signature, traits_type_, other_rep_>::const_iterator,
15899 assign<value_type> >
15900 iterator_type;
15901
15902 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
15903
15904 for_each(iterator_type(&m_data[0][0], other.begin()), size_type());
15905 }
15906
15907 LITE_INLINE array(const value_type& value)
15908 {
15909 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
15910
15911 for_each(iterator_type(&m_data[0][0], value), size_type());
15912 }
15913
15914
15915 LITE_INLINE array& operator=(const array& other)
15916 {
15917 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
15918
15919 for_each(iterator_type(
15920 &m_data[0][0],
15921 &other.m_data[0][0]),
15922 size_type());
15923 return *this;
15924 }
15925
15926 template<typename other_rep_>
15927 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
15928 {
15929 typedef b_iterator<
15930 iterator,
15931 typename array<signature, traits_type_, other_rep_>::const_iterator,
15932 assign<value_type> >
15933 iterator_type;
15934
15935 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
15936
15937 for_each(iterator_type(&m_data[0][0], other.begin()), size_type());
15938 return *this;
15939 }
15940
15941 LITE_INLINE array& operator=(const value_type& value)
15942 {
15943 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
15944
15945 for_each(iterator_type(&m_data[0][0], value), size_type());
15946 return *this;
15947 }
15948
15949 LITE_INLINE const_iterator begin() const
15950 {
15951 return const_iterator(&m_data[0][0]);
15952 }
15953
15954 LITE_INLINE iterator begin()
15955 {
15956 return iterator(&m_data[0][0]);
15957 }
15958
15959 LITE_INLINE size_type size() const
15960 {
15961 return size_type();
15962 }
15963
15964 LITE_INLINE const_reference
15965 operator()(int i0, int i1) const
15966 {
15967 return m_data[i0][i1];
15968 }
15969
15970 LITE_INLINE reference
15971 operator()(int i0, int i1)
15972 {
15973 return m_data[i0][i1];
15974 }
15975
15976
15977 template<typename transform_type_>
15978 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
15979 operator[](const transform_type_& trans) const
15980 {
15981 typedef typename transform_traits<array, transform_type_>::const_array result_type;
15982
15983 return result_type(begin(), size(), trans);
15984 }
15985
15986 template<typename transform_type_>
15987 LITE_INLINE const typename transform_traits<array, transform_type_>::array
15988 operator[](const transform_type_& trans)
15989 {
15990 typedef typename transform_traits<array, transform_type_>::array result_type;
15991
15992 return result_type(begin(), size(), trans);
15993 }
15994
15995 LITE_INLINE const value_type* data() const
15996 {
15997 return &m_data[0][0];
15998 }
15999
16000 LITE_INLINE value_type* data()
16001 {
16002 return &m_data[0][0];
16003 }
16004
16005 LITE_INLINE void release()
16006 {}
16007
16008 LITE_INLINE void resize(int, int)
16009 {}
16010
16011 LITE_INLINE void resize(const size_type&)
16012 {}
16013
16014 template<typename other_rep_>
16015 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
16016 {
16017 typedef b_iterator<
16018 iterator,
16019 typename array<signature, traits_type_, other_rep_>::const_iterator,
16020 swapper<value_type> >
16021 iterator_type;
16022
16023 for_each(iterator_type(&m_data[0][0], other.begin()), size_type());
16024 }
16025
16026 template<typename other_rep_>
16027 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
16028 {
16029 typedef b_iterator<
16030 iterator,
16031 typename array<signature, traits_type_, other_rep_>::iterator,
16032 swapper<value_type> >
16033 iterator_type;
16034
16035 for_each(iterator_type(&m_data[0][0], other.begin()), size_type());
16036 }
16037
16038 private:
16039 value_type m_data[n0_][n1_];
16040 };
16041
16042
16043
16044 template<
16045 typename value_type_,
16046 int n0_,
16047 int n1_,
16048 int n2_,
16049 typename traits_type_
16050 >
16051 class array<
16052 value_type_[n0_][n1_][n2_],
16053 traits_type_,
16054 internal_rep<false>
16055 >
16056 {
16057 public:
16058 typedef value_type_ signature[n0_][n1_][n2_];
16059 typedef traits_type_ traits_type;
16060 typedef value_type_ value_type;
16061 typedef const value_type_& const_reference;
16062 typedef value_type_& reference;
16063
16064 typedef typename array_signature_traits<const signature>::default_iterator const_iterator;
16065 typedef typename array_signature_traits<signature>::default_iterator iterator;
16066 typedef typename array_signature_traits<signature>::size_type size_type;
16067
16068 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
16069 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
16070 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
16071
16072 static const bool is_reverse = false;
16073 static const int dimensions = 3;
16074
16075 LITE_INLINE array()
16076 {}
16077
16078 explicit LITE_INLINE array(int, int, int)
16079 {}
16080
16081 explicit LITE_INLINE array(const size_type&)
16082 {}
16083
16084 LITE_INLINE array(const array& other)
16085 {
16086 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16087
16088 for_each(iterator_type(
16089 &m_data[0][0][0],
16090 &other.m_data[0][0][0]),
16091 size_type());
16092 }
16093
16094 template<typename other_rep_>
16095 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
16096 {
16097 typedef b_iterator<
16098 iterator,
16099 typename array<signature, traits_type_, other_rep_>::const_iterator,
16100 assign<value_type> >
16101 iterator_type;
16102
16103 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16104
16105 for_each(iterator_type(&m_data[0][0][0], other.begin()), size_type());
16106 }
16107
16108 LITE_INLINE array(const value_type& value)
16109 {
16110 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16111
16112 for_each(iterator_type(&m_data[0][0][0], value), size_type());
16113 }
16114
16115
16116 LITE_INLINE array& operator=(const array& other)
16117 {
16118 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16119
16120 for_each(iterator_type(
16121 &m_data[0][0][0],
16122 &other.m_data[0][0][0]),
16123 size_type());
16124 return *this;
16125 }
16126
16127 template<typename other_rep_>
16128 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
16129 {
16130 typedef b_iterator<
16131 iterator,
16132 typename array<signature, traits_type_, other_rep_>::const_iterator,
16133 assign<value_type> >
16134 iterator_type;
16135
16136 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16137
16138 for_each(iterator_type(&m_data[0][0][0], other.begin()), size_type());
16139 return *this;
16140 }
16141
16142 LITE_INLINE array& operator=(const value_type& value)
16143 {
16144 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16145
16146 for_each(iterator_type(&m_data[0][0][0], value), size_type());
16147 return *this;
16148 }
16149
16150 LITE_INLINE const_iterator begin() const
16151 {
16152 return const_iterator(&m_data[0][0][0]);
16153 }
16154
16155 LITE_INLINE iterator begin()
16156 {
16157 return iterator(&m_data[0][0][0]);
16158 }
16159
16160 LITE_INLINE size_type size() const
16161 {
16162 return size_type();
16163 }
16164
16165 LITE_INLINE const_reference
16166 operator()(int i0, int i1, int i2) const
16167 {
16168 return m_data[i0][i1][i2];
16169 }
16170
16171 LITE_INLINE reference
16172 operator()(int i0, int i1, int i2)
16173 {
16174 return m_data[i0][i1][i2];
16175 }
16176
16177
16178 template<typename transform_type_>
16179 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
16180 operator[](const transform_type_& trans) const
16181 {
16182 typedef typename transform_traits<array, transform_type_>::const_array result_type;
16183
16184 return result_type(begin(), size(), trans);
16185 }
16186
16187 template<typename transform_type_>
16188 LITE_INLINE const typename transform_traits<array, transform_type_>::array
16189 operator[](const transform_type_& trans)
16190 {
16191 typedef typename transform_traits<array, transform_type_>::array result_type;
16192
16193 return result_type(begin(), size(), trans);
16194 }
16195
16196 LITE_INLINE const value_type* data() const
16197 {
16198 return &m_data[0][0][0];
16199 }
16200
16201 LITE_INLINE value_type* data()
16202 {
16203 return &m_data[0][0][0];
16204 }
16205
16206 LITE_INLINE void release()
16207 {}
16208
16209 LITE_INLINE void resize(int, int, int)
16210 {}
16211
16212 LITE_INLINE void resize(const size_type&)
16213 {}
16214
16215 template<typename other_rep_>
16216 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
16217 {
16218 typedef b_iterator<
16219 iterator,
16220 typename array<signature, traits_type_, other_rep_>::const_iterator,
16221 swapper<value_type> >
16222 iterator_type;
16223
16224 for_each(iterator_type(&m_data[0][0][0], other.begin()), size_type());
16225 }
16226
16227 template<typename other_rep_>
16228 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
16229 {
16230 typedef b_iterator<
16231 iterator,
16232 typename array<signature, traits_type_, other_rep_>::iterator,
16233 swapper<value_type> >
16234 iterator_type;
16235
16236 for_each(iterator_type(&m_data[0][0][0], other.begin()), size_type());
16237 }
16238
16239 private:
16240 value_type m_data[n0_][n1_][n2_];
16241 };
16242
16243
16244
16245 template<
16246 typename value_type_,
16247 typename traits_type_
16248 >
16249 class array<
16250 value_type_,
16251 traits_type_,
16252 internal_rep<true>
16253 >
16254 {
16255 public:
16256 typedef value_type_ signature;
16257 typedef traits_type_ traits_type;
16258 typedef value_type_ value_type;
16259 typedef const value_type_& const_reference;
16260 typedef value_type_& reference;
16261
16262 typedef typename array_signature_traits<const signature>::default_rev_iterator const_iterator;
16263 typedef typename array_signature_traits<signature>::default_rev_iterator iterator;
16264 typedef typename array_signature_traits<signature>::size_type size_type;
16265
16266 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
16267 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
16268 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
16269
16270 static const bool is_reverse = true;
16271 static const int dimensions = 0;
16272
16273 LITE_INLINE array()
16274 {}
16275
16276
16277 explicit LITE_INLINE array(const size_type&)
16278 {}
16279
16280 LITE_INLINE array(const array& other)
16281 {
16282 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16283
16284 for_each(iterator_type(
16285 &m_data,
16286 &other.m_data),
16287 size_type());
16288 }
16289
16290 template<typename other_rep_>
16291 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
16292 {
16293 typedef b_iterator<
16294 iterator,
16295 typename array<signature, traits_type_, other_rep_>::const_iterator,
16296 assign<value_type> >
16297 iterator_type;
16298
16299 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16300
16301 for_each(iterator_type(&m_data, other.begin()), size_type());
16302 }
16303
16304 LITE_INLINE array(const value_type& value)
16305 {
16306 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16307
16308 for_each(iterator_type(&m_data, value), size_type());
16309 }
16310
16311
16312 LITE_INLINE array& operator=(const array& other)
16313 {
16314 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16315
16316 for_each(iterator_type(
16317 &m_data,
16318 &other.m_data),
16319 size_type());
16320 return *this;
16321 }
16322
16323 template<typename other_rep_>
16324 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
16325 {
16326 typedef b_iterator<
16327 iterator,
16328 typename array<signature, traits_type_, other_rep_>::const_iterator,
16329 assign<value_type> >
16330 iterator_type;
16331
16332 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16333
16334 for_each(iterator_type(&m_data, other.begin()), size_type());
16335 return *this;
16336 }
16337
16338 LITE_INLINE array& operator=(const value_type& value)
16339 {
16340 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16341
16342 for_each(iterator_type(&m_data, value), size_type());
16343 return *this;
16344 }
16345
16346 LITE_INLINE const_iterator begin() const
16347 {
16348 return const_iterator(&m_data);
16349 }
16350
16351 LITE_INLINE iterator begin()
16352 {
16353 return iterator(&m_data);
16354 }
16355
16356 LITE_INLINE size_type size() const
16357 {
16358 return size_type();
16359 }
16360
16361 LITE_INLINE const_reference
16362 operator()() const
16363 {
16364 return m_data;
16365 }
16366
16367 LITE_INLINE reference
16368 operator()()
16369 {
16370 return m_data;
16371 }
16372
16373
16374 template<typename transform_type_>
16375 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
16376 operator[](const transform_type_& trans) const
16377 {
16378 typedef typename transform_traits<array, transform_type_>::const_array result_type;
16379
16380 return result_type(begin(), size(), trans);
16381 }
16382
16383 template<typename transform_type_>
16384 LITE_INLINE const typename transform_traits<array, transform_type_>::array
16385 operator[](const transform_type_& trans)
16386 {
16387 typedef typename transform_traits<array, transform_type_>::array result_type;
16388
16389 return result_type(begin(), size(), trans);
16390 }
16391
16392 LITE_INLINE const value_type* data() const
16393 {
16394 return &m_data;
16395 }
16396
16397 LITE_INLINE value_type* data()
16398 {
16399 return &m_data;
16400 }
16401
16402 LITE_INLINE void release()
16403 {}
16404
16405 LITE_INLINE void resize()
16406 {}
16407
16408 LITE_INLINE void resize(const size_type&)
16409 {}
16410
16411 template<typename other_rep_>
16412 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
16413 {
16414 typedef b_iterator<
16415 iterator,
16416 typename array<signature, traits_type_, other_rep_>::const_iterator,
16417 swapper<value_type> >
16418 iterator_type;
16419
16420 for_each(iterator_type(&m_data, other.begin()), size_type());
16421 }
16422
16423 template<typename other_rep_>
16424 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
16425 {
16426 typedef b_iterator<
16427 iterator,
16428 typename array<signature, traits_type_, other_rep_>::iterator,
16429 swapper<value_type> >
16430 iterator_type;
16431
16432 for_each(iterator_type(&m_data, other.begin()), size_type());
16433 }
16434
16435 private:
16436 value_type m_data;
16437 };
16438
16439
16440
16441 template<
16442 typename value_type_,
16443 int n0_,
16444 typename traits_type_
16445 >
16446 class array<
16447 value_type_[n0_],
16448 traits_type_,
16449 internal_rep<true>
16450 >
16451 {
16452 public:
16453 typedef value_type_ signature[n0_];
16454 typedef traits_type_ traits_type;
16455 typedef value_type_ value_type;
16456 typedef const value_type_& const_reference;
16457 typedef value_type_& reference;
16458
16459 typedef typename array_signature_traits<const signature>::default_rev_iterator const_iterator;
16460 typedef typename array_signature_traits<signature>::default_rev_iterator iterator;
16461 typedef typename array_signature_traits<signature>::size_type size_type;
16462
16463 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
16464 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
16465 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
16466
16467 static const bool is_reverse = true;
16468 static const int dimensions = 1;
16469
16470 LITE_INLINE array()
16471 {}
16472
16473 explicit LITE_INLINE array(int)
16474 {}
16475
16476 explicit LITE_INLINE array(const size_type&)
16477 {}
16478
16479 LITE_INLINE array(const array& other)
16480 {
16481 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16482
16483 for_each(iterator_type(
16484 &m_data[0],
16485 &other.m_data[0]),
16486 size_type());
16487 }
16488
16489 template<typename other_rep_>
16490 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
16491 {
16492 typedef b_iterator<
16493 iterator,
16494 typename array<signature, traits_type_, other_rep_>::const_iterator,
16495 assign<value_type> >
16496 iterator_type;
16497
16498 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16499
16500 for_each(iterator_type(&m_data[0], other.begin()), size_type());
16501 }
16502
16503 LITE_INLINE array(const value_type& value)
16504 {
16505 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16506
16507 for_each(iterator_type(&m_data[0], value), size_type());
16508 }
16509
16510
16511 LITE_INLINE array(
16512 typename detail::type_if<n0_==2, const value_type&, detail::invalid_argument>::type a0,
16513 const value_type& a1
16514 )
16515 {
16516 m_data[0] = a0;
16517 m_data[1] = a1;
16518 }
16519
16520 LITE_INLINE array(
16521 typename detail::type_if<n0_==3, const value_type&, detail::invalid_argument>::type a0,
16522 const value_type& a1,
16523 const value_type& a2
16524 )
16525 {
16526 m_data[0] = a0;
16527 m_data[1] = a1;
16528 m_data[2] = a2;
16529 }
16530
16531 LITE_INLINE array(
16532 typename detail::type_if<n0_==4, const value_type&, detail::invalid_argument>::type a0,
16533 const value_type& a1,
16534 const value_type& a2,
16535 const value_type& a3
16536 )
16537 {
16538 m_data[0] = a0;
16539 m_data[1] = a1;
16540 m_data[2] = a2;
16541 m_data[3] = a3;
16542 }
16543
16544 LITE_INLINE array(
16545 typename detail::type_if<n0_==5, const value_type&, detail::invalid_argument>::type a0,
16546 const value_type& a1,
16547 const value_type& a2,
16548 const value_type& a3,
16549 const value_type& a4
16550 )
16551 {
16552 m_data[0] = a0;
16553 m_data[1] = a1;
16554 m_data[2] = a2;
16555 m_data[3] = a3;
16556 m_data[4] = a4;
16557 }
16558
16559 LITE_INLINE array& operator=(const array& other)
16560 {
16561 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16562
16563 for_each(iterator_type(
16564 &m_data[0],
16565 &other.m_data[0]),
16566 size_type());
16567 return *this;
16568 }
16569
16570 template<typename other_rep_>
16571 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
16572 {
16573 typedef b_iterator<
16574 iterator,
16575 typename array<signature, traits_type_, other_rep_>::const_iterator,
16576 assign<value_type> >
16577 iterator_type;
16578
16579 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16580
16581 for_each(iterator_type(&m_data[0], other.begin()), size_type());
16582 return *this;
16583 }
16584
16585 LITE_INLINE array& operator=(const value_type& value)
16586 {
16587 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16588
16589 for_each(iterator_type(&m_data[0], value), size_type());
16590 return *this;
16591 }
16592
16593 LITE_INLINE const_iterator begin() const
16594 {
16595 return const_iterator(&m_data[0]);
16596 }
16597
16598 LITE_INLINE iterator begin()
16599 {
16600 return iterator(&m_data[0]);
16601 }
16602
16603 LITE_INLINE size_type size() const
16604 {
16605 return size_type();
16606 }
16607
16608 LITE_INLINE const_reference
16609 operator()(int i0) const
16610 {
16611 return m_data[i0];
16612 }
16613
16614 LITE_INLINE reference
16615 operator()(int i0)
16616 {
16617 return m_data[i0];
16618 }
16619
16620 LITE_INLINE const_reference
16621 operator[](int i0) const
16622 {
16623 return m_data[i0];
16624 }
16625
16626 LITE_INLINE reference
16627 operator[](int i0)
16628 {
16629 return m_data[i0];
16630 }
16631
16632
16633 template<typename transform_type_>
16634 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
16635 operator[](const transform_type_& trans) const
16636 {
16637 typedef typename transform_traits<array, transform_type_>::const_array result_type;
16638
16639 return result_type(begin(), size(), trans);
16640 }
16641
16642 template<typename transform_type_>
16643 LITE_INLINE const typename transform_traits<array, transform_type_>::array
16644 operator[](const transform_type_& trans)
16645 {
16646 typedef typename transform_traits<array, transform_type_>::array result_type;
16647
16648 return result_type(begin(), size(), trans);
16649 }
16650
16651 LITE_INLINE const value_type* data() const
16652 {
16653 return &m_data[0];
16654 }
16655
16656 LITE_INLINE value_type* data()
16657 {
16658 return &m_data[0];
16659 }
16660
16661 LITE_INLINE void release()
16662 {}
16663
16664 LITE_INLINE void resize(int)
16665 {}
16666
16667 LITE_INLINE void resize(const size_type&)
16668 {}
16669
16670 template<typename other_rep_>
16671 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
16672 {
16673 typedef b_iterator<
16674 iterator,
16675 typename array<signature, traits_type_, other_rep_>::const_iterator,
16676 swapper<value_type> >
16677 iterator_type;
16678
16679 for_each(iterator_type(&m_data[0], other.begin()), size_type());
16680 }
16681
16682 template<typename other_rep_>
16683 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
16684 {
16685 typedef b_iterator<
16686 iterator,
16687 typename array<signature, traits_type_, other_rep_>::iterator,
16688 swapper<value_type> >
16689 iterator_type;
16690
16691 for_each(iterator_type(&m_data[0], other.begin()), size_type());
16692 }
16693
16694 private:
16695 value_type m_data[n0_];
16696 };
16697
16698
16699
16700 template<
16701 typename value_type_,
16702 int n0_,
16703 int n1_,
16704 typename traits_type_
16705 >
16706 class array<
16707 value_type_[n0_][n1_],
16708 traits_type_,
16709 internal_rep<true>
16710 >
16711 {
16712 public:
16713 typedef value_type_ signature[n0_][n1_];
16714 typedef traits_type_ traits_type;
16715 typedef value_type_ value_type;
16716 typedef const value_type_& const_reference;
16717 typedef value_type_& reference;
16718
16719 typedef typename array_signature_traits<const signature>::default_rev_iterator const_iterator;
16720 typedef typename array_signature_traits<signature>::default_rev_iterator iterator;
16721 typedef typename array_signature_traits<signature>::size_type size_type;
16722
16723 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
16724 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
16725 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
16726
16727 static const bool is_reverse = true;
16728 static const int dimensions = 2;
16729
16730 LITE_INLINE array()
16731 {}
16732
16733 explicit LITE_INLINE array(int, int)
16734 {}
16735
16736 explicit LITE_INLINE array(const size_type&)
16737 {}
16738
16739 LITE_INLINE array(const array& other)
16740 {
16741 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16742
16743 for_each(iterator_type(
16744 &m_data[0][0],
16745 &other.m_data[0][0]),
16746 size_type());
16747 }
16748
16749 template<typename other_rep_>
16750 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
16751 {
16752 typedef b_iterator<
16753 iterator,
16754 typename array<signature, traits_type_, other_rep_>::const_iterator,
16755 assign<value_type> >
16756 iterator_type;
16757
16758 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16759
16760 for_each(iterator_type(&m_data[0][0], other.begin()), size_type());
16761 }
16762
16763 LITE_INLINE array(const value_type& value)
16764 {
16765 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16766
16767 for_each(iterator_type(&m_data[0][0], value), size_type());
16768 }
16769
16770
16771 LITE_INLINE array& operator=(const array& other)
16772 {
16773 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16774
16775 for_each(iterator_type(
16776 &m_data[0][0],
16777 &other.m_data[0][0]),
16778 size_type());
16779 return *this;
16780 }
16781
16782 template<typename other_rep_>
16783 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
16784 {
16785 typedef b_iterator<
16786 iterator,
16787 typename array<signature, traits_type_, other_rep_>::const_iterator,
16788 assign<value_type> >
16789 iterator_type;
16790
16791 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16792
16793 for_each(iterator_type(&m_data[0][0], other.begin()), size_type());
16794 return *this;
16795 }
16796
16797 LITE_INLINE array& operator=(const value_type& value)
16798 {
16799 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16800
16801 for_each(iterator_type(&m_data[0][0], value), size_type());
16802 return *this;
16803 }
16804
16805 LITE_INLINE const_iterator begin() const
16806 {
16807 return const_iterator(&m_data[0][0]);
16808 }
16809
16810 LITE_INLINE iterator begin()
16811 {
16812 return iterator(&m_data[0][0]);
16813 }
16814
16815 LITE_INLINE size_type size() const
16816 {
16817 return size_type();
16818 }
16819
16820 LITE_INLINE const_reference
16821 operator()(int i0, int i1) const
16822 {
16823 return m_data[i1][i0];
16824 }
16825
16826 LITE_INLINE reference
16827 operator()(int i0, int i1)
16828 {
16829 return m_data[i1][i0];
16830 }
16831
16832
16833 template<typename transform_type_>
16834 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
16835 operator[](const transform_type_& trans) const
16836 {
16837 typedef typename transform_traits<array, transform_type_>::const_array result_type;
16838
16839 return result_type(begin(), size(), trans);
16840 }
16841
16842 template<typename transform_type_>
16843 LITE_INLINE const typename transform_traits<array, transform_type_>::array
16844 operator[](const transform_type_& trans)
16845 {
16846 typedef typename transform_traits<array, transform_type_>::array result_type;
16847
16848 return result_type(begin(), size(), trans);
16849 }
16850
16851 LITE_INLINE const value_type* data() const
16852 {
16853 return &m_data[0][0];
16854 }
16855
16856 LITE_INLINE value_type* data()
16857 {
16858 return &m_data[0][0];
16859 }
16860
16861 LITE_INLINE void release()
16862 {}
16863
16864 LITE_INLINE void resize(int, int)
16865 {}
16866
16867 LITE_INLINE void resize(const size_type&)
16868 {}
16869
16870 template<typename other_rep_>
16871 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
16872 {
16873 typedef b_iterator<
16874 iterator,
16875 typename array<signature, traits_type_, other_rep_>::const_iterator,
16876 swapper<value_type> >
16877 iterator_type;
16878
16879 for_each(iterator_type(&m_data[0][0], other.begin()), size_type());
16880 }
16881
16882 template<typename other_rep_>
16883 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
16884 {
16885 typedef b_iterator<
16886 iterator,
16887 typename array<signature, traits_type_, other_rep_>::iterator,
16888 swapper<value_type> >
16889 iterator_type;
16890
16891 for_each(iterator_type(&m_data[0][0], other.begin()), size_type());
16892 }
16893
16894 private:
16895 value_type m_data[n1_][n0_];
16896 };
16897
16898
16899
16900 template<
16901 typename value_type_,
16902 int n0_,
16903 int n1_,
16904 int n2_,
16905 typename traits_type_
16906 >
16907 class array<
16908 value_type_[n0_][n1_][n2_],
16909 traits_type_,
16910 internal_rep<true>
16911 >
16912 {
16913 public:
16914 typedef value_type_ signature[n0_][n1_][n2_];
16915 typedef traits_type_ traits_type;
16916 typedef value_type_ value_type;
16917 typedef const value_type_& const_reference;
16918 typedef value_type_& reference;
16919
16920 typedef typename array_signature_traits<const signature>::default_rev_iterator const_iterator;
16921 typedef typename array_signature_traits<signature>::default_rev_iterator iterator;
16922 typedef typename array_signature_traits<signature>::size_type size_type;
16923
16924 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
16925 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
16926 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
16927
16928 static const bool is_reverse = true;
16929 static const int dimensions = 3;
16930
16931 LITE_INLINE array()
16932 {}
16933
16934 explicit LITE_INLINE array(int, int, int)
16935 {}
16936
16937 explicit LITE_INLINE array(const size_type&)
16938 {}
16939
16940 LITE_INLINE array(const array& other)
16941 {
16942 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16943
16944 for_each(iterator_type(
16945 &m_data[0][0][0],
16946 &other.m_data[0][0][0]),
16947 size_type());
16948 }
16949
16950 template<typename other_rep_>
16951 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
16952 {
16953 typedef b_iterator<
16954 iterator,
16955 typename array<signature, traits_type_, other_rep_>::const_iterator,
16956 assign<value_type> >
16957 iterator_type;
16958
16959 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16960
16961 for_each(iterator_type(&m_data[0][0][0], other.begin()), size_type());
16962 }
16963
16964 LITE_INLINE array(const value_type& value)
16965 {
16966 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
16967
16968 for_each(iterator_type(&m_data[0][0][0], value), size_type());
16969 }
16970
16971
16972 LITE_INLINE array& operator=(const array& other)
16973 {
16974 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
16975
16976 for_each(iterator_type(
16977 &m_data[0][0][0],
16978 &other.m_data[0][0][0]),
16979 size_type());
16980 return *this;
16981 }
16982
16983 template<typename other_rep_>
16984 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
16985 {
16986 typedef b_iterator<
16987 iterator,
16988 typename array<signature, traits_type_, other_rep_>::const_iterator,
16989 assign<value_type> >
16990 iterator_type;
16991
16992 LITE_ARRAY_SIZE_CHECK(size_type(), other.size(), "array(): array sizes do not match");
16993
16994 for_each(iterator_type(&m_data[0][0][0], other.begin()), size_type());
16995 return *this;
16996 }
16997
16998 LITE_INLINE array& operator=(const value_type& value)
16999 {
17000 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
17001
17002 for_each(iterator_type(&m_data[0][0][0], value), size_type());
17003 return *this;
17004 }
17005
17006 LITE_INLINE const_iterator begin() const
17007 {
17008 return const_iterator(&m_data[0][0][0]);
17009 }
17010
17011 LITE_INLINE iterator begin()
17012 {
17013 return iterator(&m_data[0][0][0]);
17014 }
17015
17016 LITE_INLINE size_type size() const
17017 {
17018 return size_type();
17019 }
17020
17021 LITE_INLINE const_reference
17022 operator()(int i0, int i1, int i2) const
17023 {
17024 return m_data[i2][i1][i0];
17025 }
17026
17027 LITE_INLINE reference
17028 operator()(int i0, int i1, int i2)
17029 {
17030 return m_data[i2][i1][i0];
17031 }
17032
17033
17034 template<typename transform_type_>
17035 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
17036 operator[](const transform_type_& trans) const
17037 {
17038 typedef typename transform_traits<array, transform_type_>::const_array result_type;
17039
17040 return result_type(begin(), size(), trans);
17041 }
17042
17043 template<typename transform_type_>
17044 LITE_INLINE const typename transform_traits<array, transform_type_>::array
17045 operator[](const transform_type_& trans)
17046 {
17047 typedef typename transform_traits<array, transform_type_>::array result_type;
17048
17049 return result_type(begin(), size(), trans);
17050 }
17051
17052 LITE_INLINE const value_type* data() const
17053 {
17054 return &m_data[0][0][0];
17055 }
17056
17057 LITE_INLINE value_type* data()
17058 {
17059 return &m_data[0][0][0];
17060 }
17061
17062 LITE_INLINE void release()
17063 {}
17064
17065 LITE_INLINE void resize(int, int, int)
17066 {}
17067
17068 LITE_INLINE void resize(const size_type&)
17069 {}
17070
17071 template<typename other_rep_>
17072 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
17073 {
17074 typedef b_iterator<
17075 iterator,
17076 typename array<signature, traits_type_, other_rep_>::const_iterator,
17077 swapper<value_type> >
17078 iterator_type;
17079
17080 for_each(iterator_type(&m_data[0][0][0], other.begin()), size_type());
17081 }
17082
17083 template<typename other_rep_>
17084 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
17085 {
17086 typedef b_iterator<
17087 iterator,
17088 typename array<signature, traits_type_, other_rep_>::iterator,
17089 swapper<value_type> >
17090 iterator_type;
17091
17092 for_each(iterator_type(&m_data[0][0][0], other.begin()), size_type());
17093 }
17094
17095 private:
17096 value_type m_data[n2_][n1_][n0_];
17097 };
17098
17099
17100
17101
17102
17103
17104
17105
17113 template<bool reversed_, int internal_buf_size_>
17114 class hybrid_rep
17115 {};
17116
17117
17118 template<
17119 typename value_type_,
17120 typename traits_type_,
17121 int internal_buf_size_
17122 >
17123 class array<
17124 value_type_,
17125 traits_type_,
17126 hybrid_rep<false, internal_buf_size_>
17127 >
17128 {
17129 public:
17130 typedef value_type_ signature;
17131 typedef traits_type_ traits_type;
17132 typedef value_type_ value_type;
17133 typedef const value_type_& const_reference;
17134 typedef value_type_& reference;
17135
17136 typedef typename array_signature_traits<const signature>::default_iterator const_iterator;
17137 typedef typename array_signature_traits<signature>::default_iterator iterator;
17138 typedef typename array_signature_traits<signature>::size_type size_type;
17139
17140 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
17141 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
17142 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
17143
17144 static const int dimensions = 0;
17145 static const bool is_reverse = false;
17146 static const int internal_buffer_size = internal_buf_size_;
17147
17148
17149
17150 explicit LITE_INLINE array(const size_type& sz)
17151 {
17152 init();
17153 resize(sz);
17154 }
17155
17156 LITE_INLINE array(const array& other)
17157 {
17158 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
17159
17160 init();
17161 resize(other.size());
17162 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
17163 }
17164
17165 template<typename other_rep_>
17166 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
17167 {
17168 typedef b_iterator<
17169 iterator,
17170 typename array<signature, traits_type_, other_rep_>::const_iterator,
17171 assign<value_type> >
17172 iterator_type;
17173
17174 init();
17175 resize(other.size());
17176 for_each(iterator_type(m_iterator, other.begin()), m_size);
17177 }
17178
17179 LITE_INLINE array(const value_type& value)
17180 {
17181 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
17182
17183 init();
17184 for_each(iterator_type(m_iterator, value), m_size);
17185 }
17186
17187 LITE_INLINE array& operator=(const array& other)
17188 {
17189 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
17190
17191 resize(other.size());
17192 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
17193 return *this;
17194 }
17195
17196 template<typename other_rep_>
17197 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
17198 {
17199 typedef b_iterator<
17200 iterator,
17201 typename array<signature, traits_type_, other_rep_>::const_iterator,
17202 assign<value_type> >
17203 iterator_type;
17204
17205 resize(other.size());
17206 for_each(iterator_type(m_iterator, other.begin()), m_size);
17207 return *this;
17208 }
17209
17210 LITE_INLINE array& operator=(const value_type& value)
17211 {
17212 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
17213
17214 for_each(iterator_type(m_iterator, value), m_size);
17215 return *this;
17216 }
17217
17218 LITE_INLINE const_iterator begin() const
17219 {
17220 return m_iterator;
17221 }
17222
17223 LITE_INLINE iterator begin()
17224 {
17225 return m_iterator;
17226 }
17227
17228 LITE_INLINE size_type size() const
17229 {
17230 return m_size;
17231 }
17232
17233 LITE_INLINE const_reference
17234 operator()() const
17235 {
17236 return *(m_iterator.i0);
17237 }
17238
17239 LITE_INLINE reference
17240 operator()()
17241 {
17242 return *(m_iterator.i0);
17243 }
17244
17245
17246 template<typename transform_type_>
17247 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
17248 operator[](const transform_type_& trans) const
17249 {
17250 typedef typename transform_traits<array, transform_type_>::const_array result_type;
17251
17252 return result_type(begin(), size(), trans);
17253 }
17254
17255 template<typename transform_type_>
17256 LITE_INLINE const typename transform_traits<array, transform_type_>::array
17257 operator[](const transform_type_& trans)
17258 {
17259 typedef typename transform_traits<array, transform_type_>::array result_type;
17260
17261 return result_type(begin(), size(), trans);
17262 }
17263
17264 LITE_INLINE const value_type* data() const
17265 {
17266 return m_iterator.i0;
17267 }
17268
17269 LITE_INLINE value_type* data()
17270 {
17271 return m_iterator.i0;
17272 }
17273
17274 LITE_INLINE void release()
17275 {
17276 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17277 delete m_iterator.i0;
17278
17279 m_iterator.i0 = 0;
17280 m_size.set();
17281 }
17282
17283 LITE_INLINE void resize()
17284 {
17285 resize(size_type());
17286 }
17287
17288 LITE_INLINE void resize(const size_type& new_size)
17289 {
17290 int old_volumne = volume(m_size);
17291 int new_volume = volume(new_size);
17292
17293 if (old_volumne != new_volume || m_iterator.i0==0) {
17294 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17295 delete m_iterator.i0;
17296 m_iterator.i0 = 0;
17297 m_size.set();
17298
17299 if (new_volume == 0)
17300 return;
17301
17302 m_iterator.i0 = new_volume <= internal_buffer_size ? m_buffer : new value_type[new_volume];
17303 }
17304 m_size = new_size;
17305 m_iterator.set(
17306 m_iterator.i0
17307 );
17308 }
17309
17310 template<typename other_rep_>
17311 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
17312 {
17313 regular_swap(other);
17314 }
17315
17316 template<typename other_rep_>
17317 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
17318 {
17319 regular_swap(other);
17320 }
17321
17322 LITE_INLINE void swap(array& other)
17323 {
17324
17325 if (m_iterator.i0 != m_buffer && other.m_iterator.i0 != other.m_buffer) {
17326 iterator tmp_iter = other.m_iterator;
17327 size_type tmp_size = other.m_size;
17328
17329 other.m_iterator = m_iterator;
17330 other.m_size = m_size;
17331
17332 m_iterator = tmp_iter;
17333 m_size = tmp_size;
17334 }
17335 else
17336 regular_swap(other);
17337 }
17338
17339
17340 LITE_INLINE ~array()
17341 {
17342 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17343 delete m_iterator.i0;
17344 }
17345
17346 private:
17347
17348 template<typename other_array_>
17349 LITE_INLINE void regular_swap(other_array_& other)
17350 {
17351 typedef b_iterator<iterator, typename other_array_::iterator, swapper<value_type> > iterator_type;
17352
17353 if (m_size == other.size())
17354 for_each(iterator_type(m_iterator, other.begin()), m_size);
17355 else {
17356 typename other_array_::temporary_array tmp = other;
17357
17358 other = *this;
17359 *this = tmp;
17360 }
17361 }
17362
17363 template<typename other_signature_, typename other_traits_type_, typename other_rep_>
17364 friend class array;
17365
17366 LITE_INLINE void init()
17367 {
17368 m_iterator.i0 = 0;
17369 m_size.set();
17370 resize(m_size);
17371 }
17372
17373 iterator m_iterator;
17374 size_type m_size;
17375 value_type m_buffer[internal_buffer_size >= 1 ? internal_buffer_size : 1];
17376 };
17377
17378
17379
17380 template<
17381 typename value_type_,
17382 int n0_,
17383 typename traits_type_,
17384 int internal_buf_size_
17385 >
17386 class array<
17387 value_type_[n0_],
17388 traits_type_,
17389 hybrid_rep<false, internal_buf_size_>
17390 >
17391 {
17392 public:
17393 typedef value_type_ signature[n0_];
17394 typedef traits_type_ traits_type;
17395 typedef value_type_ value_type;
17396 typedef const value_type_& const_reference;
17397 typedef value_type_& reference;
17398
17399 typedef typename array_signature_traits<const signature>::default_iterator const_iterator;
17400 typedef typename array_signature_traits<signature>::default_iterator iterator;
17401 typedef typename array_signature_traits<signature>::size_type size_type;
17402
17403 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
17404 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
17405 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
17406
17407 static const int dimensions = 1;
17408 static const bool is_reverse = false;
17409 static const int internal_buffer_size = internal_buf_size_;
17410
17411 LITE_INLINE array()
17412 {
17413 init();
17414 resize(size_type());
17415 }
17416
17417 explicit LITE_INLINE array(int n0)
17418 {
17419 init();
17420 resize(size_type(n0));
17421 }
17422
17423 explicit LITE_INLINE array(const size_type& sz)
17424 {
17425 init();
17426 resize(sz);
17427 }
17428
17429 LITE_INLINE array(const array& other)
17430 {
17431 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
17432
17433 init();
17434 resize(other.size());
17435 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
17436 }
17437
17438 template<typename other_rep_>
17439 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
17440 {
17441 typedef b_iterator<
17442 iterator,
17443 typename array<signature, traits_type_, other_rep_>::const_iterator,
17444 assign<value_type> >
17445 iterator_type;
17446
17447 init();
17448 resize(other.size());
17449 for_each(iterator_type(m_iterator, other.begin()), m_size);
17450 }
17451
17452 LITE_INLINE array(const value_type& value)
17453 {
17454 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
17455
17456 init();
17457 for_each(iterator_type(m_iterator, value), m_size);
17458 }
17459
17460 LITE_INLINE array& operator=(const array& other)
17461 {
17462 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
17463
17464 resize(other.size());
17465 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
17466 return *this;
17467 }
17468
17469 template<typename other_rep_>
17470 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
17471 {
17472 typedef b_iterator<
17473 iterator,
17474 typename array<signature, traits_type_, other_rep_>::const_iterator,
17475 assign<value_type> >
17476 iterator_type;
17477
17478 resize(other.size());
17479 for_each(iterator_type(m_iterator, other.begin()), m_size);
17480 return *this;
17481 }
17482
17483 LITE_INLINE array& operator=(const value_type& value)
17484 {
17485 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
17486
17487 for_each(iterator_type(m_iterator, value), m_size);
17488 return *this;
17489 }
17490
17491 LITE_INLINE const_iterator begin() const
17492 {
17493 return m_iterator;
17494 }
17495
17496 LITE_INLINE iterator begin()
17497 {
17498 return m_iterator;
17499 }
17500
17501 LITE_INLINE size_type size() const
17502 {
17503 return m_size;
17504 }
17505
17506 LITE_INLINE const_reference
17507 operator()(int i0) const
17508 {
17509 return *(m_iterator.i0+i0*m_iterator.i1);
17510 }
17511
17512 LITE_INLINE reference
17513 operator()(int i0)
17514 {
17515 return *(m_iterator.i0+i0*m_iterator.i1);
17516 }
17517
17518 LITE_INLINE const_reference
17519 operator[](int i0) const
17520 {
17521 return *(m_iterator.i0+i0*m_iterator.i1);
17522 }
17523
17524 LITE_INLINE reference
17525 operator[](int i0)
17526 {
17527 return *(m_iterator.i0+i0*m_iterator.i1);
17528 }
17529
17530
17531 template<typename transform_type_>
17532 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
17533 operator[](const transform_type_& trans) const
17534 {
17535 typedef typename transform_traits<array, transform_type_>::const_array result_type;
17536
17537 return result_type(begin(), size(), trans);
17538 }
17539
17540 template<typename transform_type_>
17541 LITE_INLINE const typename transform_traits<array, transform_type_>::array
17542 operator[](const transform_type_& trans)
17543 {
17544 typedef typename transform_traits<array, transform_type_>::array result_type;
17545
17546 return result_type(begin(), size(), trans);
17547 }
17548
17549 LITE_INLINE const value_type* data() const
17550 {
17551 return m_iterator.i0;
17552 }
17553
17554 LITE_INLINE value_type* data()
17555 {
17556 return m_iterator.i0;
17557 }
17558
17559 LITE_INLINE void release()
17560 {
17561 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17562 delete m_iterator.i0;
17563
17564 m_iterator.i0 = 0;
17565 m_size.set(0);
17566 }
17567
17568 LITE_INLINE void resize(int n0)
17569 {
17570 resize(size_type(n0));
17571 }
17572
17573 LITE_INLINE void resize(const size_type& new_size)
17574 {
17575 int old_volumne = volume(m_size);
17576 int new_volume = volume(new_size);
17577
17578 if (old_volumne != new_volume || m_iterator.i0==0) {
17579 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17580 delete m_iterator.i0;
17581 m_iterator.i0 = 0;
17582 m_size.set(0);
17583
17584 if (new_volume == 0)
17585 return;
17586
17587 m_iterator.i0 = new_volume <= internal_buffer_size ? m_buffer : new value_type[new_volume];
17588 }
17589 m_size = new_size;
17590 m_iterator.set(
17591 m_iterator.i0,
17592 1
17593 );
17594 }
17595
17596 template<typename other_rep_>
17597 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
17598 {
17599 regular_swap(other);
17600 }
17601
17602 template<typename other_rep_>
17603 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
17604 {
17605 regular_swap(other);
17606 }
17607
17608 LITE_INLINE void swap(array& other)
17609 {
17610
17611 if (m_iterator.i0 != m_buffer && other.m_iterator.i0 != other.m_buffer) {
17612 iterator tmp_iter = other.m_iterator;
17613 size_type tmp_size = other.m_size;
17614
17615 other.m_iterator = m_iterator;
17616 other.m_size = m_size;
17617
17618 m_iterator = tmp_iter;
17619 m_size = tmp_size;
17620 }
17621 else
17622 regular_swap(other);
17623 }
17624
17625
17626 LITE_INLINE ~array()
17627 {
17628 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17629 delete m_iterator.i0;
17630 }
17631
17632 private:
17633
17634 template<typename other_array_>
17635 LITE_INLINE void regular_swap(other_array_& other)
17636 {
17637 typedef b_iterator<iterator, typename other_array_::iterator, swapper<value_type> > iterator_type;
17638
17639 if (m_size == other.size())
17640 for_each(iterator_type(m_iterator, other.begin()), m_size);
17641 else {
17642 typename other_array_::temporary_array tmp = other;
17643
17644 other = *this;
17645 *this = tmp;
17646 }
17647 }
17648
17649 template<typename other_signature_, typename other_traits_type_, typename other_rep_>
17650 friend class array;
17651
17652 LITE_INLINE void init()
17653 {
17654 m_iterator.i0 = 0;
17655 m_size.set(0);
17656 resize(m_size);
17657 }
17658
17659 iterator m_iterator;
17660 size_type m_size;
17661 value_type m_buffer[internal_buffer_size >= 1 ? internal_buffer_size : 1];
17662 };
17663
17664
17665
17666 template<
17667 typename value_type_,
17668 int n0_,
17669 int n1_,
17670 typename traits_type_,
17671 int internal_buf_size_
17672 >
17673 class array<
17674 value_type_[n0_][n1_],
17675 traits_type_,
17676 hybrid_rep<false, internal_buf_size_>
17677 >
17678 {
17679 public:
17680 typedef value_type_ signature[n0_][n1_];
17681 typedef traits_type_ traits_type;
17682 typedef value_type_ value_type;
17683 typedef const value_type_& const_reference;
17684 typedef value_type_& reference;
17685
17686 typedef typename array_signature_traits<const signature>::default_iterator const_iterator;
17687 typedef typename array_signature_traits<signature>::default_iterator iterator;
17688 typedef typename array_signature_traits<signature>::size_type size_type;
17689
17690 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
17691 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
17692 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
17693
17694 static const int dimensions = 2;
17695 static const bool is_reverse = false;
17696 static const int internal_buffer_size = internal_buf_size_;
17697
17698 LITE_INLINE array()
17699 {
17700 init();
17701 resize(size_type());
17702 }
17703
17704 explicit LITE_INLINE array(int n0, int n1)
17705 {
17706 init();
17707 resize(size_type(n0, n1));
17708 }
17709
17710 explicit LITE_INLINE array(const size_type& sz)
17711 {
17712 init();
17713 resize(sz);
17714 }
17715
17716 LITE_INLINE array(const array& other)
17717 {
17718 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
17719
17720 init();
17721 resize(other.size());
17722 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
17723 }
17724
17725 template<typename other_rep_>
17726 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
17727 {
17728 typedef b_iterator<
17729 iterator,
17730 typename array<signature, traits_type_, other_rep_>::const_iterator,
17731 assign<value_type> >
17732 iterator_type;
17733
17734 init();
17735 resize(other.size());
17736 for_each(iterator_type(m_iterator, other.begin()), m_size);
17737 }
17738
17739 LITE_INLINE array(const value_type& value)
17740 {
17741 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
17742
17743 init();
17744 for_each(iterator_type(m_iterator, value), m_size);
17745 }
17746
17747 LITE_INLINE array& operator=(const array& other)
17748 {
17749 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
17750
17751 resize(other.size());
17752 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
17753 return *this;
17754 }
17755
17756 template<typename other_rep_>
17757 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
17758 {
17759 typedef b_iterator<
17760 iterator,
17761 typename array<signature, traits_type_, other_rep_>::const_iterator,
17762 assign<value_type> >
17763 iterator_type;
17764
17765 resize(other.size());
17766 for_each(iterator_type(m_iterator, other.begin()), m_size);
17767 return *this;
17768 }
17769
17770 LITE_INLINE array& operator=(const value_type& value)
17771 {
17772 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
17773
17774 for_each(iterator_type(m_iterator, value), m_size);
17775 return *this;
17776 }
17777
17778 LITE_INLINE const_iterator begin() const
17779 {
17780 return m_iterator;
17781 }
17782
17783 LITE_INLINE iterator begin()
17784 {
17785 return m_iterator;
17786 }
17787
17788 LITE_INLINE size_type size() const
17789 {
17790 return m_size;
17791 }
17792
17793 LITE_INLINE const_reference
17794 operator()(int i0, int i1) const
17795 {
17796 return *(m_iterator.i0+i0*m_iterator.i1+i1*m_iterator.i2);
17797 }
17798
17799 LITE_INLINE reference
17800 operator()(int i0, int i1)
17801 {
17802 return *(m_iterator.i0+i0*m_iterator.i1+i1*m_iterator.i2);
17803 }
17804
17805
17806 template<typename transform_type_>
17807 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
17808 operator[](const transform_type_& trans) const
17809 {
17810 typedef typename transform_traits<array, transform_type_>::const_array result_type;
17811
17812 return result_type(begin(), size(), trans);
17813 }
17814
17815 template<typename transform_type_>
17816 LITE_INLINE const typename transform_traits<array, transform_type_>::array
17817 operator[](const transform_type_& trans)
17818 {
17819 typedef typename transform_traits<array, transform_type_>::array result_type;
17820
17821 return result_type(begin(), size(), trans);
17822 }
17823
17824 LITE_INLINE const value_type* data() const
17825 {
17826 return m_iterator.i0;
17827 }
17828
17829 LITE_INLINE value_type* data()
17830 {
17831 return m_iterator.i0;
17832 }
17833
17834 LITE_INLINE void release()
17835 {
17836 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17837 delete m_iterator.i0;
17838
17839 m_iterator.i0 = 0;
17840 m_size.set(0, 0);
17841 }
17842
17843 LITE_INLINE void resize(int n0, int n1)
17844 {
17845 resize(size_type(n0, n1));
17846 }
17847
17848 LITE_INLINE void resize(const size_type& new_size)
17849 {
17850 int old_volumne = volume(m_size);
17851 int new_volume = volume(new_size);
17852
17853 if (old_volumne != new_volume || m_iterator.i0==0) {
17854 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17855 delete m_iterator.i0;
17856 m_iterator.i0 = 0;
17857 m_size.set(0, 0);
17858
17859 if (new_volume == 0)
17860 return;
17861
17862 m_iterator.i0 = new_volume <= internal_buffer_size ? m_buffer : new value_type[new_volume];
17863 }
17864 m_size = new_size;
17865 m_iterator.set(
17866 m_iterator.i0,
17867 m_size.i1,
17868 1
17869 );
17870 }
17871
17872 template<typename other_rep_>
17873 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
17874 {
17875 regular_swap(other);
17876 }
17877
17878 template<typename other_rep_>
17879 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
17880 {
17881 regular_swap(other);
17882 }
17883
17884 LITE_INLINE void swap(array& other)
17885 {
17886
17887 if (m_iterator.i0 != m_buffer && other.m_iterator.i0 != other.m_buffer) {
17888 iterator tmp_iter = other.m_iterator;
17889 size_type tmp_size = other.m_size;
17890
17891 other.m_iterator = m_iterator;
17892 other.m_size = m_size;
17893
17894 m_iterator = tmp_iter;
17895 m_size = tmp_size;
17896 }
17897 else
17898 regular_swap(other);
17899 }
17900
17901
17902 LITE_INLINE ~array()
17903 {
17904 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
17905 delete m_iterator.i0;
17906 }
17907
17908 private:
17909
17910 template<typename other_array_>
17911 LITE_INLINE void regular_swap(other_array_& other)
17912 {
17913 typedef b_iterator<iterator, typename other_array_::iterator, swapper<value_type> > iterator_type;
17914
17915 if (m_size == other.size())
17916 for_each(iterator_type(m_iterator, other.begin()), m_size);
17917 else {
17918 typename other_array_::temporary_array tmp = other;
17919
17920 other = *this;
17921 *this = tmp;
17922 }
17923 }
17924
17925 template<typename other_signature_, typename other_traits_type_, typename other_rep_>
17926 friend class array;
17927
17928 LITE_INLINE void init()
17929 {
17930 m_iterator.i0 = 0;
17931 m_size.set(0, 0);
17932 resize(m_size);
17933 }
17934
17935 iterator m_iterator;
17936 size_type m_size;
17937 value_type m_buffer[internal_buffer_size >= 1 ? internal_buffer_size : 1];
17938 };
17939
17940
17941
17942 template<
17943 typename value_type_,
17944 int n0_,
17945 int n1_,
17946 int n2_,
17947 typename traits_type_,
17948 int internal_buf_size_
17949 >
17950 class array<
17951 value_type_[n0_][n1_][n2_],
17952 traits_type_,
17953 hybrid_rep<false, internal_buf_size_>
17954 >
17955 {
17956 public:
17957 typedef value_type_ signature[n0_][n1_][n2_];
17958 typedef traits_type_ traits_type;
17959 typedef value_type_ value_type;
17960 typedef const value_type_& const_reference;
17961 typedef value_type_& reference;
17962
17963 typedef typename array_signature_traits<const signature>::default_iterator const_iterator;
17964 typedef typename array_signature_traits<signature>::default_iterator iterator;
17965 typedef typename array_signature_traits<signature>::size_type size_type;
17966
17967 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
17968 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
17969 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
17970
17971 static const int dimensions = 3;
17972 static const bool is_reverse = false;
17973 static const int internal_buffer_size = internal_buf_size_;
17974
17975 LITE_INLINE array()
17976 {
17977 init();
17978 resize(size_type());
17979 }
17980
17981 explicit LITE_INLINE array(int n0, int n1, int n2)
17982 {
17983 init();
17984 resize(size_type(n0, n1, n2));
17985 }
17986
17987 explicit LITE_INLINE array(const size_type& sz)
17988 {
17989 init();
17990 resize(sz);
17991 }
17992
17993 LITE_INLINE array(const array& other)
17994 {
17995 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
17996
17997 init();
17998 resize(other.size());
17999 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
18000 }
18001
18002 template<typename other_rep_>
18003 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
18004 {
18005 typedef b_iterator<
18006 iterator,
18007 typename array<signature, traits_type_, other_rep_>::const_iterator,
18008 assign<value_type> >
18009 iterator_type;
18010
18011 init();
18012 resize(other.size());
18013 for_each(iterator_type(m_iterator, other.begin()), m_size);
18014 }
18015
18016 LITE_INLINE array(const value_type& value)
18017 {
18018 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
18019
18020 init();
18021 for_each(iterator_type(m_iterator, value), m_size);
18022 }
18023
18024 LITE_INLINE array& operator=(const array& other)
18025 {
18026 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
18027
18028 resize(other.size());
18029 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
18030 return *this;
18031 }
18032
18033 template<typename other_rep_>
18034 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
18035 {
18036 typedef b_iterator<
18037 iterator,
18038 typename array<signature, traits_type_, other_rep_>::const_iterator,
18039 assign<value_type> >
18040 iterator_type;
18041
18042 resize(other.size());
18043 for_each(iterator_type(m_iterator, other.begin()), m_size);
18044 return *this;
18045 }
18046
18047 LITE_INLINE array& operator=(const value_type& value)
18048 {
18049 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
18050
18051 for_each(iterator_type(m_iterator, value), m_size);
18052 return *this;
18053 }
18054
18055 LITE_INLINE const_iterator begin() const
18056 {
18057 return m_iterator;
18058 }
18059
18060 LITE_INLINE iterator begin()
18061 {
18062 return m_iterator;
18063 }
18064
18065 LITE_INLINE size_type size() const
18066 {
18067 return m_size;
18068 }
18069
18070 LITE_INLINE const_reference
18071 operator()(int i0, int i1, int i2) const
18072 {
18073 return *(m_iterator.i0+i0*m_iterator.i1+i1*m_iterator.i2+i2*m_iterator.i3);
18074 }
18075
18076 LITE_INLINE reference
18077 operator()(int i0, int i1, int i2)
18078 {
18079 return *(m_iterator.i0+i0*m_iterator.i1+i1*m_iterator.i2+i2*m_iterator.i3);
18080 }
18081
18082
18083 template<typename transform_type_>
18084 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
18085 operator[](const transform_type_& trans) const
18086 {
18087 typedef typename transform_traits<array, transform_type_>::const_array result_type;
18088
18089 return result_type(begin(), size(), trans);
18090 }
18091
18092 template<typename transform_type_>
18093 LITE_INLINE const typename transform_traits<array, transform_type_>::array
18094 operator[](const transform_type_& trans)
18095 {
18096 typedef typename transform_traits<array, transform_type_>::array result_type;
18097
18098 return result_type(begin(), size(), trans);
18099 }
18100
18101 LITE_INLINE const value_type* data() const
18102 {
18103 return m_iterator.i0;
18104 }
18105
18106 LITE_INLINE value_type* data()
18107 {
18108 return m_iterator.i0;
18109 }
18110
18111 LITE_INLINE void release()
18112 {
18113 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18114 delete m_iterator.i0;
18115
18116 m_iterator.i0 = 0;
18117 m_size.set(0, 0, 0);
18118 }
18119
18120 LITE_INLINE void resize(int n0, int n1, int n2)
18121 {
18122 resize(size_type(n0, n1, n2));
18123 }
18124
18125 LITE_INLINE void resize(const size_type& new_size)
18126 {
18127 int old_volumne = volume(m_size);
18128 int new_volume = volume(new_size);
18129
18130 if (old_volumne != new_volume || m_iterator.i0==0) {
18131 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18132 delete m_iterator.i0;
18133 m_iterator.i0 = 0;
18134 m_size.set(0, 0, 0);
18135
18136 if (new_volume == 0)
18137 return;
18138
18139 m_iterator.i0 = new_volume <= internal_buffer_size ? m_buffer : new value_type[new_volume];
18140 }
18141 m_size = new_size;
18142 m_iterator.set(
18143 m_iterator.i0,
18144 m_size.i1*m_size.i2,
18145 m_size.i2,
18146 1
18147 );
18148 }
18149
18150 template<typename other_rep_>
18151 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
18152 {
18153 regular_swap(other);
18154 }
18155
18156 template<typename other_rep_>
18157 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
18158 {
18159 regular_swap(other);
18160 }
18161
18162 LITE_INLINE void swap(array& other)
18163 {
18164
18165 if (m_iterator.i0 != m_buffer && other.m_iterator.i0 != other.m_buffer) {
18166 iterator tmp_iter = other.m_iterator;
18167 size_type tmp_size = other.m_size;
18168
18169 other.m_iterator = m_iterator;
18170 other.m_size = m_size;
18171
18172 m_iterator = tmp_iter;
18173 m_size = tmp_size;
18174 }
18175 else
18176 regular_swap(other);
18177 }
18178
18179
18180 LITE_INLINE ~array()
18181 {
18182 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18183 delete m_iterator.i0;
18184 }
18185
18186 private:
18187
18188 template<typename other_array_>
18189 LITE_INLINE void regular_swap(other_array_& other)
18190 {
18191 typedef b_iterator<iterator, typename other_array_::iterator, swapper<value_type> > iterator_type;
18192
18193 if (m_size == other.size())
18194 for_each(iterator_type(m_iterator, other.begin()), m_size);
18195 else {
18196 typename other_array_::temporary_array tmp = other;
18197
18198 other = *this;
18199 *this = tmp;
18200 }
18201 }
18202
18203 template<typename other_signature_, typename other_traits_type_, typename other_rep_>
18204 friend class array;
18205
18206 LITE_INLINE void init()
18207 {
18208 m_iterator.i0 = 0;
18209 m_size.set(0, 0, 0);
18210 resize(m_size);
18211 }
18212
18213 iterator m_iterator;
18214 size_type m_size;
18215 value_type m_buffer[internal_buffer_size >= 1 ? internal_buffer_size : 1];
18216 };
18217
18218
18219
18220 template<
18221 typename value_type_,
18222 typename traits_type_,
18223 int internal_buf_size_
18224 >
18225 class array<
18226 value_type_,
18227 traits_type_,
18228 hybrid_rep<true, internal_buf_size_>
18229 >
18230 {
18231 public:
18232 typedef value_type_ signature;
18233 typedef traits_type_ traits_type;
18234 typedef value_type_ value_type;
18235 typedef const value_type_& const_reference;
18236 typedef value_type_& reference;
18237
18238 typedef typename array_signature_traits<const signature>::default_rev_iterator const_iterator;
18239 typedef typename array_signature_traits<signature>::default_rev_iterator iterator;
18240 typedef typename array_signature_traits<signature>::size_type size_type;
18241
18242 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
18243 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
18244 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
18245
18246 static const int dimensions = 0;
18247 static const bool is_reverse = true;
18248 static const int internal_buffer_size = internal_buf_size_;
18249
18250
18251
18252 explicit LITE_INLINE array(const size_type& sz)
18253 {
18254 init();
18255 resize(sz);
18256 }
18257
18258 LITE_INLINE array(const array& other)
18259 {
18260 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
18261
18262 init();
18263 resize(other.size());
18264 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
18265 }
18266
18267 template<typename other_rep_>
18268 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
18269 {
18270 typedef b_iterator<
18271 iterator,
18272 typename array<signature, traits_type_, other_rep_>::const_iterator,
18273 assign<value_type> >
18274 iterator_type;
18275
18276 init();
18277 resize(other.size());
18278 for_each(iterator_type(m_iterator, other.begin()), m_size);
18279 }
18280
18281 LITE_INLINE array(const value_type& value)
18282 {
18283 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
18284
18285 init();
18286 for_each(iterator_type(m_iterator, value), m_size);
18287 }
18288
18289 LITE_INLINE array& operator=(const array& other)
18290 {
18291 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
18292
18293 resize(other.size());
18294 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
18295 return *this;
18296 }
18297
18298 template<typename other_rep_>
18299 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
18300 {
18301 typedef b_iterator<
18302 iterator,
18303 typename array<signature, traits_type_, other_rep_>::const_iterator,
18304 assign<value_type> >
18305 iterator_type;
18306
18307 resize(other.size());
18308 for_each(iterator_type(m_iterator, other.begin()), m_size);
18309 return *this;
18310 }
18311
18312 LITE_INLINE array& operator=(const value_type& value)
18313 {
18314 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
18315
18316 for_each(iterator_type(m_iterator, value), m_size);
18317 return *this;
18318 }
18319
18320 LITE_INLINE const_iterator begin() const
18321 {
18322 return m_iterator;
18323 }
18324
18325 LITE_INLINE iterator begin()
18326 {
18327 return m_iterator;
18328 }
18329
18330 LITE_INLINE size_type size() const
18331 {
18332 return m_size;
18333 }
18334
18335 LITE_INLINE const_reference
18336 operator()() const
18337 {
18338 return *(m_iterator.i0);
18339 }
18340
18341 LITE_INLINE reference
18342 operator()()
18343 {
18344 return *(m_iterator.i0);
18345 }
18346
18347
18348 template<typename transform_type_>
18349 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
18350 operator[](const transform_type_& trans) const
18351 {
18352 typedef typename transform_traits<array, transform_type_>::const_array result_type;
18353
18354 return result_type(begin(), size(), trans);
18355 }
18356
18357 template<typename transform_type_>
18358 LITE_INLINE const typename transform_traits<array, transform_type_>::array
18359 operator[](const transform_type_& trans)
18360 {
18361 typedef typename transform_traits<array, transform_type_>::array result_type;
18362
18363 return result_type(begin(), size(), trans);
18364 }
18365
18366 LITE_INLINE const value_type* data() const
18367 {
18368 return m_iterator.i0;
18369 }
18370
18371 LITE_INLINE value_type* data()
18372 {
18373 return m_iterator.i0;
18374 }
18375
18376 LITE_INLINE void release()
18377 {
18378 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18379 delete m_iterator.i0;
18380
18381 m_iterator.i0 = 0;
18382 m_size.set();
18383 }
18384
18385 LITE_INLINE void resize()
18386 {
18387 resize(size_type());
18388 }
18389
18390 LITE_INLINE void resize(const size_type& new_size)
18391 {
18392 int old_volumne = volume(m_size);
18393 int new_volume = volume(new_size);
18394
18395 if (old_volumne != new_volume || m_iterator.i0==0) {
18396 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18397 delete m_iterator.i0;
18398 m_iterator.i0 = 0;
18399 m_size.set();
18400
18401 if (new_volume == 0)
18402 return;
18403
18404 m_iterator.i0 = new_volume <= internal_buffer_size ? m_buffer : new value_type[new_volume];
18405 }
18406 m_size = new_size;
18407 m_iterator.set(
18408 m_iterator.i0
18409 );
18410 }
18411
18412 template<typename other_rep_>
18413 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
18414 {
18415 regular_swap(other);
18416 }
18417
18418 template<typename other_rep_>
18419 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
18420 {
18421 regular_swap(other);
18422 }
18423
18424 LITE_INLINE void swap(array& other)
18425 {
18426
18427 if (m_iterator.i0 != m_buffer && other.m_iterator.i0 != other.m_buffer) {
18428 iterator tmp_iter = other.m_iterator;
18429 size_type tmp_size = other.m_size;
18430
18431 other.m_iterator = m_iterator;
18432 other.m_size = m_size;
18433
18434 m_iterator = tmp_iter;
18435 m_size = tmp_size;
18436 }
18437 else
18438 regular_swap(other);
18439 }
18440
18441
18442 LITE_INLINE ~array()
18443 {
18444 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18445 delete m_iterator.i0;
18446 }
18447
18448 private:
18449
18450 template<typename other_array_>
18451 LITE_INLINE void regular_swap(other_array_& other)
18452 {
18453 typedef b_iterator<iterator, typename other_array_::iterator, swapper<value_type> > iterator_type;
18454
18455 if (m_size == other.size())
18456 for_each(iterator_type(m_iterator, other.begin()), m_size);
18457 else {
18458 typename other_array_::temporary_array tmp = other;
18459
18460 other = *this;
18461 *this = tmp;
18462 }
18463 }
18464
18465 template<typename other_signature_, typename other_traits_type_, typename other_rep_>
18466 friend class array;
18467
18468 LITE_INLINE void init()
18469 {
18470 m_iterator.i0 = 0;
18471 m_size.set();
18472 resize(m_size);
18473 }
18474
18475 iterator m_iterator;
18476 size_type m_size;
18477 value_type m_buffer[internal_buffer_size >= 1 ? internal_buffer_size : 1];
18478 };
18479
18480
18481
18482 template<
18483 typename value_type_,
18484 int n0_,
18485 typename traits_type_,
18486 int internal_buf_size_
18487 >
18488 class array<
18489 value_type_[n0_],
18490 traits_type_,
18491 hybrid_rep<true, internal_buf_size_>
18492 >
18493 {
18494 public:
18495 typedef value_type_ signature[n0_];
18496 typedef traits_type_ traits_type;
18497 typedef value_type_ value_type;
18498 typedef const value_type_& const_reference;
18499 typedef value_type_& reference;
18500
18501 typedef typename array_signature_traits<const signature>::default_rev_iterator const_iterator;
18502 typedef typename array_signature_traits<signature>::default_rev_iterator iterator;
18503 typedef typename array_signature_traits<signature>::size_type size_type;
18504
18505 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
18506 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
18507 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
18508
18509 static const int dimensions = 1;
18510 static const bool is_reverse = true;
18511 static const int internal_buffer_size = internal_buf_size_;
18512
18513 LITE_INLINE array()
18514 {
18515 init();
18516 resize(size_type());
18517 }
18518
18519 explicit LITE_INLINE array(int n0)
18520 {
18521 init();
18522 resize(size_type(n0));
18523 }
18524
18525 explicit LITE_INLINE array(const size_type& sz)
18526 {
18527 init();
18528 resize(sz);
18529 }
18530
18531 LITE_INLINE array(const array& other)
18532 {
18533 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
18534
18535 init();
18536 resize(other.size());
18537 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
18538 }
18539
18540 template<typename other_rep_>
18541 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
18542 {
18543 typedef b_iterator<
18544 iterator,
18545 typename array<signature, traits_type_, other_rep_>::const_iterator,
18546 assign<value_type> >
18547 iterator_type;
18548
18549 init();
18550 resize(other.size());
18551 for_each(iterator_type(m_iterator, other.begin()), m_size);
18552 }
18553
18554 LITE_INLINE array(const value_type& value)
18555 {
18556 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
18557
18558 init();
18559 for_each(iterator_type(m_iterator, value), m_size);
18560 }
18561
18562 LITE_INLINE array& operator=(const array& other)
18563 {
18564 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
18565
18566 resize(other.size());
18567 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
18568 return *this;
18569 }
18570
18571 template<typename other_rep_>
18572 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
18573 {
18574 typedef b_iterator<
18575 iterator,
18576 typename array<signature, traits_type_, other_rep_>::const_iterator,
18577 assign<value_type> >
18578 iterator_type;
18579
18580 resize(other.size());
18581 for_each(iterator_type(m_iterator, other.begin()), m_size);
18582 return *this;
18583 }
18584
18585 LITE_INLINE array& operator=(const value_type& value)
18586 {
18587 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
18588
18589 for_each(iterator_type(m_iterator, value), m_size);
18590 return *this;
18591 }
18592
18593 LITE_INLINE const_iterator begin() const
18594 {
18595 return m_iterator;
18596 }
18597
18598 LITE_INLINE iterator begin()
18599 {
18600 return m_iterator;
18601 }
18602
18603 LITE_INLINE size_type size() const
18604 {
18605 return m_size;
18606 }
18607
18608 LITE_INLINE const_reference
18609 operator()(int i0) const
18610 {
18611 return *(m_iterator.i0+i0*m_iterator.i1);
18612 }
18613
18614 LITE_INLINE reference
18615 operator()(int i0)
18616 {
18617 return *(m_iterator.i0+i0*m_iterator.i1);
18618 }
18619
18620 LITE_INLINE const_reference
18621 operator[](int i0) const
18622 {
18623 return *(m_iterator.i0+i0*m_iterator.i1);
18624 }
18625
18626 LITE_INLINE reference
18627 operator[](int i0)
18628 {
18629 return *(m_iterator.i0+i0*m_iterator.i1);
18630 }
18631
18632
18633 template<typename transform_type_>
18634 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
18635 operator[](const transform_type_& trans) const
18636 {
18637 typedef typename transform_traits<array, transform_type_>::const_array result_type;
18638
18639 return result_type(begin(), size(), trans);
18640 }
18641
18642 template<typename transform_type_>
18643 LITE_INLINE const typename transform_traits<array, transform_type_>::array
18644 operator[](const transform_type_& trans)
18645 {
18646 typedef typename transform_traits<array, transform_type_>::array result_type;
18647
18648 return result_type(begin(), size(), trans);
18649 }
18650
18651 LITE_INLINE const value_type* data() const
18652 {
18653 return m_iterator.i0;
18654 }
18655
18656 LITE_INLINE value_type* data()
18657 {
18658 return m_iterator.i0;
18659 }
18660
18661 LITE_INLINE void release()
18662 {
18663 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18664 delete m_iterator.i0;
18665
18666 m_iterator.i0 = 0;
18667 m_size.set(0);
18668 }
18669
18670 LITE_INLINE void resize(int n0)
18671 {
18672 resize(size_type(n0));
18673 }
18674
18675 LITE_INLINE void resize(const size_type& new_size)
18676 {
18677 int old_volumne = volume(m_size);
18678 int new_volume = volume(new_size);
18679
18680 if (old_volumne != new_volume || m_iterator.i0==0) {
18681 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18682 delete m_iterator.i0;
18683 m_iterator.i0 = 0;
18684 m_size.set(0);
18685
18686 if (new_volume == 0)
18687 return;
18688
18689 m_iterator.i0 = new_volume <= internal_buffer_size ? m_buffer : new value_type[new_volume];
18690 }
18691 m_size = new_size;
18692 m_iterator.set(
18693 m_iterator.i0,
18694 1
18695 );
18696 }
18697
18698 template<typename other_rep_>
18699 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
18700 {
18701 regular_swap(other);
18702 }
18703
18704 template<typename other_rep_>
18705 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
18706 {
18707 regular_swap(other);
18708 }
18709
18710 LITE_INLINE void swap(array& other)
18711 {
18712
18713 if (m_iterator.i0 != m_buffer && other.m_iterator.i0 != other.m_buffer) {
18714 iterator tmp_iter = other.m_iterator;
18715 size_type tmp_size = other.m_size;
18716
18717 other.m_iterator = m_iterator;
18718 other.m_size = m_size;
18719
18720 m_iterator = tmp_iter;
18721 m_size = tmp_size;
18722 }
18723 else
18724 regular_swap(other);
18725 }
18726
18727
18728 LITE_INLINE ~array()
18729 {
18730 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18731 delete m_iterator.i0;
18732 }
18733
18734 private:
18735
18736 template<typename other_array_>
18737 LITE_INLINE void regular_swap(other_array_& other)
18738 {
18739 typedef b_iterator<iterator, typename other_array_::iterator, swapper<value_type> > iterator_type;
18740
18741 if (m_size == other.size())
18742 for_each(iterator_type(m_iterator, other.begin()), m_size);
18743 else {
18744 typename other_array_::temporary_array tmp = other;
18745
18746 other = *this;
18747 *this = tmp;
18748 }
18749 }
18750
18751 template<typename other_signature_, typename other_traits_type_, typename other_rep_>
18752 friend class array;
18753
18754 LITE_INLINE void init()
18755 {
18756 m_iterator.i0 = 0;
18757 m_size.set(0);
18758 resize(m_size);
18759 }
18760
18761 iterator m_iterator;
18762 size_type m_size;
18763 value_type m_buffer[internal_buffer_size >= 1 ? internal_buffer_size : 1];
18764 };
18765
18766
18767
18768 template<
18769 typename value_type_,
18770 int n0_,
18771 int n1_,
18772 typename traits_type_,
18773 int internal_buf_size_
18774 >
18775 class array<
18776 value_type_[n0_][n1_],
18777 traits_type_,
18778 hybrid_rep<true, internal_buf_size_>
18779 >
18780 {
18781 public:
18782 typedef value_type_ signature[n0_][n1_];
18783 typedef traits_type_ traits_type;
18784 typedef value_type_ value_type;
18785 typedef const value_type_& const_reference;
18786 typedef value_type_& reference;
18787
18788 typedef typename array_signature_traits<const signature>::default_rev_iterator const_iterator;
18789 typedef typename array_signature_traits<signature>::default_rev_iterator iterator;
18790 typedef typename array_signature_traits<signature>::size_type size_type;
18791
18792 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
18793 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
18794 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
18795
18796 static const int dimensions = 2;
18797 static const bool is_reverse = true;
18798 static const int internal_buffer_size = internal_buf_size_;
18799
18800 LITE_INLINE array()
18801 {
18802 init();
18803 resize(size_type());
18804 }
18805
18806 explicit LITE_INLINE array(int n0, int n1)
18807 {
18808 init();
18809 resize(size_type(n0, n1));
18810 }
18811
18812 explicit LITE_INLINE array(const size_type& sz)
18813 {
18814 init();
18815 resize(sz);
18816 }
18817
18818 LITE_INLINE array(const array& other)
18819 {
18820 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
18821
18822 init();
18823 resize(other.size());
18824 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
18825 }
18826
18827 template<typename other_rep_>
18828 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
18829 {
18830 typedef b_iterator<
18831 iterator,
18832 typename array<signature, traits_type_, other_rep_>::const_iterator,
18833 assign<value_type> >
18834 iterator_type;
18835
18836 init();
18837 resize(other.size());
18838 for_each(iterator_type(m_iterator, other.begin()), m_size);
18839 }
18840
18841 LITE_INLINE array(const value_type& value)
18842 {
18843 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
18844
18845 init();
18846 for_each(iterator_type(m_iterator, value), m_size);
18847 }
18848
18849 LITE_INLINE array& operator=(const array& other)
18850 {
18851 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
18852
18853 resize(other.size());
18854 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
18855 return *this;
18856 }
18857
18858 template<typename other_rep_>
18859 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
18860 {
18861 typedef b_iterator<
18862 iterator,
18863 typename array<signature, traits_type_, other_rep_>::const_iterator,
18864 assign<value_type> >
18865 iterator_type;
18866
18867 resize(other.size());
18868 for_each(iterator_type(m_iterator, other.begin()), m_size);
18869 return *this;
18870 }
18871
18872 LITE_INLINE array& operator=(const value_type& value)
18873 {
18874 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
18875
18876 for_each(iterator_type(m_iterator, value), m_size);
18877 return *this;
18878 }
18879
18880 LITE_INLINE const_iterator begin() const
18881 {
18882 return m_iterator;
18883 }
18884
18885 LITE_INLINE iterator begin()
18886 {
18887 return m_iterator;
18888 }
18889
18890 LITE_INLINE size_type size() const
18891 {
18892 return m_size;
18893 }
18894
18895 LITE_INLINE const_reference
18896 operator()(int i0, int i1) const
18897 {
18898 return *(m_iterator.i0+i0*m_iterator.i1+i1*m_iterator.i2);
18899 }
18900
18901 LITE_INLINE reference
18902 operator()(int i0, int i1)
18903 {
18904 return *(m_iterator.i0+i0*m_iterator.i1+i1*m_iterator.i2);
18905 }
18906
18907
18908 template<typename transform_type_>
18909 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
18910 operator[](const transform_type_& trans) const
18911 {
18912 typedef typename transform_traits<array, transform_type_>::const_array result_type;
18913
18914 return result_type(begin(), size(), trans);
18915 }
18916
18917 template<typename transform_type_>
18918 LITE_INLINE const typename transform_traits<array, transform_type_>::array
18919 operator[](const transform_type_& trans)
18920 {
18921 typedef typename transform_traits<array, transform_type_>::array result_type;
18922
18923 return result_type(begin(), size(), trans);
18924 }
18925
18926 LITE_INLINE const value_type* data() const
18927 {
18928 return m_iterator.i0;
18929 }
18930
18931 LITE_INLINE value_type* data()
18932 {
18933 return m_iterator.i0;
18934 }
18935
18936 LITE_INLINE void release()
18937 {
18938 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18939 delete m_iterator.i0;
18940
18941 m_iterator.i0 = 0;
18942 m_size.set(0, 0);
18943 }
18944
18945 LITE_INLINE void resize(int n0, int n1)
18946 {
18947 resize(size_type(n0, n1));
18948 }
18949
18950 LITE_INLINE void resize(const size_type& new_size)
18951 {
18952 int old_volumne = volume(m_size);
18953 int new_volume = volume(new_size);
18954
18955 if (old_volumne != new_volume || m_iterator.i0==0) {
18956 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
18957 delete m_iterator.i0;
18958 m_iterator.i0 = 0;
18959 m_size.set(0, 0);
18960
18961 if (new_volume == 0)
18962 return;
18963
18964 m_iterator.i0 = new_volume <= internal_buffer_size ? m_buffer : new value_type[new_volume];
18965 }
18966 m_size = new_size;
18967 m_iterator.set(
18968 m_iterator.i0,
18969 1,
18970 m_size.i0
18971 );
18972 }
18973
18974 template<typename other_rep_>
18975 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
18976 {
18977 regular_swap(other);
18978 }
18979
18980 template<typename other_rep_>
18981 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
18982 {
18983 regular_swap(other);
18984 }
18985
18986 LITE_INLINE void swap(array& other)
18987 {
18988
18989 if (m_iterator.i0 != m_buffer && other.m_iterator.i0 != other.m_buffer) {
18990 iterator tmp_iter = other.m_iterator;
18991 size_type tmp_size = other.m_size;
18992
18993 other.m_iterator = m_iterator;
18994 other.m_size = m_size;
18995
18996 m_iterator = tmp_iter;
18997 m_size = tmp_size;
18998 }
18999 else
19000 regular_swap(other);
19001 }
19002
19003
19004 LITE_INLINE ~array()
19005 {
19006 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
19007 delete m_iterator.i0;
19008 }
19009
19010 private:
19011
19012 template<typename other_array_>
19013 LITE_INLINE void regular_swap(other_array_& other)
19014 {
19015 typedef b_iterator<iterator, typename other_array_::iterator, swapper<value_type> > iterator_type;
19016
19017 if (m_size == other.size())
19018 for_each(iterator_type(m_iterator, other.begin()), m_size);
19019 else {
19020 typename other_array_::temporary_array tmp = other;
19021
19022 other = *this;
19023 *this = tmp;
19024 }
19025 }
19026
19027 template<typename other_signature_, typename other_traits_type_, typename other_rep_>
19028 friend class array;
19029
19030 LITE_INLINE void init()
19031 {
19032 m_iterator.i0 = 0;
19033 m_size.set(0, 0);
19034 resize(m_size);
19035 }
19036
19037 iterator m_iterator;
19038 size_type m_size;
19039 value_type m_buffer[internal_buffer_size >= 1 ? internal_buffer_size : 1];
19040 };
19041
19042
19043
19044 template<
19045 typename value_type_,
19046 int n0_,
19047 int n1_,
19048 int n2_,
19049 typename traits_type_,
19050 int internal_buf_size_
19051 >
19052 class array<
19053 value_type_[n0_][n1_][n2_],
19054 traits_type_,
19055 hybrid_rep<true, internal_buf_size_>
19056 >
19057 {
19058 public:
19059 typedef value_type_ signature[n0_][n1_][n2_];
19060 typedef traits_type_ traits_type;
19061 typedef value_type_ value_type;
19062 typedef const value_type_& const_reference;
19063 typedef value_type_& reference;
19064
19065 typedef typename array_signature_traits<const signature>::default_rev_iterator const_iterator;
19066 typedef typename array_signature_traits<signature>::default_rev_iterator iterator;
19067 typedef typename array_signature_traits<signature>::size_type size_type;
19068
19069 typedef typename array_helper<signature, traits_type_>::temporary_array temporary_array;
19070 typedef typename array_helper<signature, traits_type_>::fwd_temporary_array fwd_temporary_array;
19071 typedef typename array_helper<signature, traits_type_>::rev_temporary_array rev_temporary_array;
19072
19073 static const int dimensions = 3;
19074 static const bool is_reverse = true;
19075 static const int internal_buffer_size = internal_buf_size_;
19076
19077 LITE_INLINE array()
19078 {
19079 init();
19080 resize(size_type());
19081 }
19082
19083 explicit LITE_INLINE array(int n0, int n1, int n2)
19084 {
19085 init();
19086 resize(size_type(n0, n1, n2));
19087 }
19088
19089 explicit LITE_INLINE array(const size_type& sz)
19090 {
19091 init();
19092 resize(sz);
19093 }
19094
19095 LITE_INLINE array(const array& other)
19096 {
19097 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
19098
19099 init();
19100 resize(other.size());
19101 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
19102 }
19103
19104 template<typename other_rep_>
19105 LITE_INLINE array(const array<signature, traits_type_, other_rep_>& other)
19106 {
19107 typedef b_iterator<
19108 iterator,
19109 typename array<signature, traits_type_, other_rep_>::const_iterator,
19110 assign<value_type> >
19111 iterator_type;
19112
19113 init();
19114 resize(other.size());
19115 for_each(iterator_type(m_iterator, other.begin()), m_size);
19116 }
19117
19118 LITE_INLINE array(const value_type& value)
19119 {
19120 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
19121
19122 init();
19123 for_each(iterator_type(m_iterator, value), m_size);
19124 }
19125
19126 LITE_INLINE array& operator=(const array& other)
19127 {
19128 typedef b_iterator<iterator, const_iterator, assign<value_type> > iterator_type;
19129
19130 resize(other.size());
19131 for_each(iterator_type(m_iterator, other.m_iterator), m_size);
19132 return *this;
19133 }
19134
19135 template<typename other_rep_>
19136 LITE_INLINE array& operator=(const array<signature, traits_type_, other_rep_>& other)
19137 {
19138 typedef b_iterator<
19139 iterator,
19140 typename array<signature, traits_type_, other_rep_>::const_iterator,
19141 assign<value_type> >
19142 iterator_type;
19143
19144 resize(other.size());
19145 for_each(iterator_type(m_iterator, other.begin()), m_size);
19146 return *this;
19147 }
19148
19149 LITE_INLINE array& operator=(const value_type& value)
19150 {
19151 typedef b_iterator<iterator, c_iterator<value_type>, assign<value_type> > iterator_type;
19152
19153 for_each(iterator_type(m_iterator, value), m_size);
19154 return *this;
19155 }
19156
19157 LITE_INLINE const_iterator begin() const
19158 {
19159 return m_iterator;
19160 }
19161
19162 LITE_INLINE iterator begin()
19163 {
19164 return m_iterator;
19165 }
19166
19167 LITE_INLINE size_type size() const
19168 {
19169 return m_size;
19170 }
19171
19172 LITE_INLINE const_reference
19173 operator()(int i0, int i1, int i2) const
19174 {
19175 return *(m_iterator.i0+i0*m_iterator.i1+i1*m_iterator.i2+i2*m_iterator.i3);
19176 }
19177
19178 LITE_INLINE reference
19179 operator()(int i0, int i1, int i2)
19180 {
19181 return *(m_iterator.i0+i0*m_iterator.i1+i1*m_iterator.i2+i2*m_iterator.i3);
19182 }
19183
19184
19185 template<typename transform_type_>
19186 LITE_INLINE const typename transform_traits<array, transform_type_>::const_array
19187 operator[](const transform_type_& trans) const
19188 {
19189 typedef typename transform_traits<array, transform_type_>::const_array result_type;
19190
19191 return result_type(begin(), size(), trans);
19192 }
19193
19194 template<typename transform_type_>
19195 LITE_INLINE const typename transform_traits<array, transform_type_>::array
19196 operator[](const transform_type_& trans)
19197 {
19198 typedef typename transform_traits<array, transform_type_>::array result_type;
19199
19200 return result_type(begin(), size(), trans);
19201 }
19202
19203 LITE_INLINE const value_type* data() const
19204 {
19205 return m_iterator.i0;
19206 }
19207
19208 LITE_INLINE value_type* data()
19209 {
19210 return m_iterator.i0;
19211 }
19212
19213 LITE_INLINE void release()
19214 {
19215 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
19216 delete m_iterator.i0;
19217
19218 m_iterator.i0 = 0;
19219 m_size.set(0, 0, 0);
19220 }
19221
19222 LITE_INLINE void resize(int n0, int n1, int n2)
19223 {
19224 resize(size_type(n0, n1, n2));
19225 }
19226
19227 LITE_INLINE void resize(const size_type& new_size)
19228 {
19229 int old_volumne = volume(m_size);
19230 int new_volume = volume(new_size);
19231
19232 if (old_volumne != new_volume || m_iterator.i0==0) {
19233 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
19234 delete m_iterator.i0;
19235 m_iterator.i0 = 0;
19236 m_size.set(0, 0, 0);
19237
19238 if (new_volume == 0)
19239 return;
19240
19241 m_iterator.i0 = new_volume <= internal_buffer_size ? m_buffer : new value_type[new_volume];
19242 }
19243 m_size = new_size;
19244 m_iterator.set(
19245 m_iterator.i0,
19246 1,
19247 m_size.i0,
19248 m_size.i0*m_size.i1
19249 );
19250 }
19251
19252 template<typename other_rep_>
19253 LITE_INLINE void swap(const array<signature, traits_type_, other_rep_>& other)
19254 {
19255 regular_swap(other);
19256 }
19257
19258 template<typename other_rep_>
19259 LITE_INLINE void swap(array<signature, traits_type_, other_rep_>& other)
19260 {
19261 regular_swap(other);
19262 }
19263
19264 LITE_INLINE void swap(array& other)
19265 {
19266
19267 if (m_iterator.i0 != m_buffer && other.m_iterator.i0 != other.m_buffer) {
19268 iterator tmp_iter = other.m_iterator;
19269 size_type tmp_size = other.m_size;
19270
19271 other.m_iterator = m_iterator;
19272 other.m_size = m_size;
19273
19274 m_iterator = tmp_iter;
19275 m_size = tmp_size;
19276 }
19277 else
19278 regular_swap(other);
19279 }
19280
19281
19282 LITE_INLINE ~array()
19283 {
19284 if (m_iterator.i0 && m_iterator.i0 != m_buffer)
19285 delete m_iterator.i0;
19286 }
19287
19288 private:
19289
19290 template<typename other_array_>
19291 LITE_INLINE void regular_swap(other_array_& other)
19292 {
19293 typedef b_iterator<iterator, typename other_array_::iterator, swapper<value_type> > iterator_type;
19294
19295 if (m_size == other.size())
19296 for_each(iterator_type(m_iterator, other.begin()), m_size);
19297 else {
19298 typename other_array_::temporary_array tmp = other;
19299
19300 other = *this;
19301 *this = tmp;
19302 }
19303 }
19304
19305 template<typename other_signature_, typename other_traits_type_, typename other_rep_>
19306 friend class array;
19307
19308 LITE_INLINE void init()
19309 {
19310 m_iterator.i0 = 0;
19311 m_size.set(0, 0, 0);
19312 resize(m_size);
19313 }
19314
19315 iterator m_iterator;
19316 size_type m_size;
19317 value_type m_buffer[internal_buffer_size >= 1 ? internal_buffer_size : 1];
19318 };
19319
19320
19321
19322
19323
19324
19325
19326
19327 #ifdef DOCUMENTATION_ONLY
19328
19357 template<typename array_type_, typename trans_type_>
19358 struct transform_traits
19359 {
19361 typedef typename size_transformer<trans_type_, typename array_type_::size_type>::size_type size_type;
19362
19364 typedef typename detail::size_to_signature<size_type, typename array_type_::value_type>::type signature;
19365
19367 typedef typename array_type_::traits_type traits_type;
19368
19370 typedef typename iterator_transformer<
19371 trans_type_,
19372 typename array_type_::iterator,
19373 typename array_type_::size_type>::iterator_type iterator;
19374
19376 typedef typename iterator_transformer<
19377 trans_type_,
19378 typename array_type_::const_iterator,
19379 typename array_type_::size_type>::iterator_type const_iterator;
19380
19382 typedef ::lite::array<signature, traits_type, reference_rep<iterator> > array;
19383
19385 typedef ::lite::array<signature, traits_type, reference_rep<const_iterator> > const_array;
19386
19392 typedef typename array_helper<signature, traits_type>::temporary_array temporary_array;
19393
19399 typedef typename array_helper<signature, traits_type>::fwd_temporary_array fwd_temporary_array;
19400
19406 typedef typename array_helper<signature, traits_type>::rev_temporary_array rev_temporary_array;
19407 };
19408
19409 #else // DOCUMENTATION_ONLY
19410
19411 template<typename array_type_, typename trans_type_>
19412 struct transform_traits<
19413 array_type_,
19414 trans_type_,
19415 typename detail::enable_if<
19416 detail::defined<typename size_transformer<trans_type_,
19417 typename array_type_::size_type>::size_type>::value
19418 >::type
19419 >
19420 {
19421 typedef typename size_transformer<trans_type_, typename array_type_::size_type>::size_type size_type;
19422 typedef typename detail::size_to_signature<size_type, typename array_type_::value_type>::type signature;
19423 typedef typename array_type_::traits_type traits_type;
19424
19425 typedef typename iterator_transformer<
19426 trans_type_,
19427 typename array_type_::iterator,
19428 typename array_type_::size_type>::iterator_type iterator;
19429
19430 typedef typename iterator_transformer<
19431 trans_type_,
19432 typename array_type_::const_iterator,
19433 typename array_type_::size_type>::iterator_type const_iterator;
19434
19435 typedef ::lite::array<signature, traits_type, reference_rep<iterator> > array;
19436 typedef ::lite::array<signature, traits_type, reference_rep<const_iterator> > const_array;
19437
19438 typedef typename array_helper<signature, traits_type>::temporary_array temporary_array;
19439 typedef typename array_helper<signature, traits_type>::fwd_temporary_array fwd_temporary_array;
19440 typedef typename array_helper<signature, traits_type>::rev_temporary_array rev_temporary_array;
19441 };
19442
19443 #endif // DOCUMENTATION_ONLY
19444
19445
19446
19447
19448
19449 template<typename type_>
19450 class uplus
19451 {
19452 public:
19453 typedef type_ argument_type;
19454 typedef type_ result_type;
19455
19456 LITE_INLINE result_type operator()(const argument_type& a) const
19457 { return +a; }
19458 };
19459
19460 template<typename type_>
19461 class negate
19462 {
19463 public:
19464 typedef type_ argument_type;
19465 typedef type_ result_type;
19466
19467 LITE_INLINE result_type operator()(const argument_type& a) const
19468 { return -a; }
19469 };
19470
19471 template<typename type_>
19472 class plus
19473 {
19474 public:
19475 typedef type_ first_argument_type;
19476 typedef type_ second_argument_type;
19477 typedef type_ result_type;
19478
19479 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19480 { return a + b; }
19481 };
19482
19483 template<typename type_>
19484 class minus
19485 {
19486 public:
19487 typedef type_ first_argument_type;
19488 typedef type_ second_argument_type;
19489 typedef type_ result_type;
19490
19491 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19492 { return a - b; }
19493 };
19494
19495 template<typename type_>
19496 class multiplies
19497 {
19498 public:
19499 typedef type_ first_argument_type;
19500 typedef type_ second_argument_type;
19501 typedef type_ result_type;
19502
19503 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19504 { return a*b; }
19505 };
19506
19507 template<typename type_>
19508 class divides
19509 {
19510 public:
19511 typedef type_ first_argument_type;
19512 typedef type_ second_argument_type;
19513 typedef type_ result_type;
19514
19515 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19516 { return a/b; }
19517 };
19518
19519 template<typename type_>
19520 class assign
19521 {
19522 public:
19523 typedef type_ first_argument_type;
19524 typedef type_ second_argument_type;
19525 typedef type_& result_type;
19526
19527 LITE_INLINE result_type operator()(first_argument_type& a, const second_argument_type& b) const
19528 { return a = b; }
19529 };
19530
19531 template<typename type_>
19532 class plus_assign
19533 {
19534 public:
19535 typedef type_ first_argument_type;
19536 typedef type_ second_argument_type;
19537 typedef type_& result_type;
19538
19539 LITE_INLINE result_type operator()(first_argument_type& a, const second_argument_type& b) const
19540 { return a += b; }
19541 };
19542
19543 template<typename type_>
19544 class minus_assign
19545 {
19546 public:
19547 typedef type_ first_argument_type;
19548 typedef type_ second_argument_type;
19549 typedef type_& result_type;
19550
19551 LITE_INLINE result_type operator()(first_argument_type& a, const second_argument_type& b) const
19552 { return a -= b; }
19553 };
19554
19555 template<typename type_>
19556 class multiplies_assign
19557 {
19558 public:
19559 typedef type_ first_argument_type;
19560 typedef type_ second_argument_type;
19561 typedef type_& result_type;
19562
19563 LITE_INLINE result_type operator()(first_argument_type& a, const second_argument_type& b) const
19564 { return a *= b; }
19565 };
19566
19567 template<typename type_>
19568 class divides_assign
19569 {
19570 public:
19571 typedef type_ first_argument_type;
19572 typedef type_ second_argument_type;
19573 typedef type_& result_type;
19574
19575 LITE_INLINE result_type operator()(first_argument_type& a, const second_argument_type& b) const
19576 { return a /= b; }
19577 };
19578
19579 template<typename type_>
19580 class minimum
19581 {
19582 public:
19583 typedef type_ first_argument_type;
19584 typedef type_ second_argument_type;
19585 typedef const type_& result_type;
19586
19587 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19588 { return a < b ? a : b; }
19589 };
19590
19591 template<typename type_>
19592 class maximum
19593 {
19594 public:
19595 typedef type_ first_argument_type;
19596 typedef type_ second_argument_type;
19597 typedef const type_& result_type;
19598
19599 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19600 { return a > b ? a : b; }
19601 };
19602
19603 template<typename type_>
19604 class square
19605 {
19606 public:
19607 typedef type_ argument_type;
19608 typedef type_ result_type;
19609
19610 LITE_INLINE result_type operator()(const argument_type& a) const
19611 { return a*a; }
19612 };
19613
19614 template<typename type_>
19615 class less
19616 {
19617 public:
19618 typedef type_ first_argument_type;
19619 typedef type_ second_argument_type;
19620 typedef bool result_type;
19621
19622 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19623 { return a < b; }
19624 };
19625
19626 template<typename type_>
19627 class less_equal
19628 {
19629 public:
19630 typedef type_ first_argument_type;
19631 typedef type_ second_argument_type;
19632 typedef bool result_type;
19633
19634 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19635 { return a <= b; }
19636 };
19637
19638 template<typename type_>
19639 class equal_to
19640 {
19641 public:
19642 typedef type_ first_argument_type;
19643 typedef type_ second_argument_type;
19644 typedef bool result_type;
19645
19646 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19647 { return a == b; }
19648 };
19649
19650 template<typename type_>
19651 class greater_equal
19652 {
19653 public:
19654 typedef type_ first_argument_type;
19655 typedef type_ second_argument_type;
19656 typedef bool result_type;
19657
19658 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19659 { return a >= b; }
19660 };
19661
19662 template<typename type_>
19663 class greater
19664 {
19665 public:
19666 typedef type_ first_argument_type;
19667 typedef type_ second_argument_type;
19668 typedef bool result_type;
19669
19670 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19671 { return a > b; }
19672 };
19673
19674 template<typename type_>
19675 class compare3
19676 {
19677 public:
19678 typedef type_ first_argument_type;
19679 typedef type_ second_argument_type;
19680 typedef int result_type;
19681
19682 LITE_INLINE result_type operator()(const first_argument_type& a, const second_argument_type& b) const
19683 { return a < b ? -1 : b < a ? 1 : 0; }
19684 };
19685
19686 template<typename type_>
19687 class round
19688 {
19689 public:
19690 typedef type_ argument_type;
19691 typedef type_ result_type;
19692
19693 round(const type_& normal = type_(1)) : m_normal(normal) {}
19694
19695 LITE_INLINE result_type operator()(const argument_type& a) const
19696 { return (a+m_normal)-m_normal; }
19697
19698 private:
19699 type_ m_normal;
19700 };
19701
19702 template<typename type_>
19703 class accumulator
19704 {
19705 public:
19706 typedef type_ argument_type;
19707 typedef void result_type;
19708
19709 LITE_INLINE accumulator(const type_& value = type_())
19710 : m_value(value)
19711 {}
19712
19713 LITE_INLINE accumulator(const accumulator& other)
19714 : m_value(other.m_value)
19715 {}
19716
19717 LITE_INLINE accumulator& operator=(const accumulator& other)
19718 {
19719 m_value = other.m_value;
19720 return *this;
19721 }
19722
19723 LITE_INLINE void operator()(const argument_type& a)
19724 {
19725 m_value += a;
19726 }
19727
19728 LITE_INLINE type_ operator()() const
19729 {
19730 return m_value;
19731 }
19732
19733 private:
19734 type_ m_value;
19735 };
19736
19737 template<typename type_>
19738 class while_equal
19739 {
19740 public:
19741 typedef type_ argument_type;
19742 typedef bool result_type;
19743
19744 LITE_INLINE while_equal(): m_result() {}
19745
19746 LITE_INLINE while_equal(const while_equal& other) : m_result(other.m_result) {}
19747
19748 LITE_INLINE while_equal& operator=(const while_equal& other)
19749 {
19750 m_result = other.m_result;
19751 return *this;
19752 }
19753
19754 LITE_INLINE result_type operator()(const argument_type& a)
19755 {
19756 if (a == 0)
19757 return true;
19758
19759 m_result = a;
19760 return false;
19761 }
19762
19763 LITE_INLINE argument_type operator()() const
19764 {
19765 return m_result;
19766 }
19767
19768 private:
19769 argument_type m_result;
19770 };
19771
19772
19773 template<typename type_>
19774 class swapper
19775 {
19776 public:
19777 typedef type_ first_argument_type;
19778 typedef type_ second_argument_type;
19779 typedef bool result_type;
19780
19781 LITE_INLINE result_type operator()(first_argument_type& a, second_argument_type& b) const
19782 {
19783 std::swap(a, b);
19784 return true;
19785 }
19786 };
19787
19788
19789
19790
19791
19792 template<typename func_type_, typename signature_, typename traits_type_, typename rep_>
19793 LITE_INLINE array<signature_, traits_type_, reference_rep<u_iterator<
19794 typename array<signature_,traits_type_, rep_>::const_iterator,
19795 func_type_>
19796 > >
19797 apply(const array<signature_, traits_type_, rep_>& a)
19798 {
19799 typedef array<signature_, traits_type_, reference_rep<u_iterator<
19800 typename array<signature_,traits_type_, rep_>::const_iterator,
19801 func_type_> >
19802 > result_type;
19803
19804 return result_type(a.begin(), a.size());
19805 }
19806
19807 template<typename func_type_, typename signature_, typename traits_type_, typename rep_>
19808 LITE_INLINE array<signature_, traits_type_, reference_rep<u_iterator<
19809 typename array<signature_,traits_type_, rep_>::iterator,
19810 func_type_>
19811 > >
19812 apply(array<signature_, traits_type_, rep_>& a)
19813 {
19814 typedef array<signature_, traits_type_, reference_rep<u_iterator<
19815 typename array<signature_,traits_type_, rep_>::iterator,
19816 func_type_> >
19817 > result_type;
19818
19819 return result_type(a.begin(), a.size());
19820 }
19821
19822
19823
19824
19825
19826 template<typename func_type_, typename signature_, typename traits_type_, typename rep_>
19827 LITE_INLINE array<signature_, traits_type_, reference_rep<u_iterator<
19828 typename array<signature_,traits_type_, rep_>::const_iterator,
19829 func_type_,
19830 false>
19831 > >
19832 apply(const array<signature_, traits_type_, rep_>& a, const func_type_& func)
19833 {
19834 typedef array<signature_, traits_type_, reference_rep<u_iterator<
19835 typename array<signature_,traits_type_, rep_>::const_iterator,
19836 func_type_,
19837 false> >
19838 > result_type;
19839
19840 return result_type(a.begin(), func, a.size());
19841 }
19842
19843 template<typename func_type_, typename signature_, typename traits_type_, typename rep_>
19844 LITE_INLINE array<signature_, traits_type_, reference_rep<u_iterator<
19845 typename array<signature_,traits_type_, rep_>::iterator,
19846 func_type_,
19847 false>
19848 > >
19849 apply(array<signature_, traits_type_, rep_>& a, const func_type_& func)
19850 {
19851 typedef array<signature_, traits_type_, reference_rep<u_iterator<
19852 typename array<signature_,traits_type_, rep_>::iterator,
19853 func_type_,
19854 false> >
19855 > result_type;
19856
19857 return result_type(a.begin(), func, a.size());
19858 }
19859
19860
19861
19862
19863
19864
19865 template<typename func_type_, typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
19866 LITE_INLINE
19867 array<signature_, traits_type_, reference_rep<b_iterator<
19868 typename array<signature_,traits_type_, l_rep_>::const_iterator,
19869 typename array<signature_,traits_type_, r_rep_>::const_iterator,
19870 func_type_>
19871 > >
19872 apply(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
19873 {
19874 typedef array<signature_, traits_type_, reference_rep<b_iterator<
19875 typename array<signature_,traits_type_, l_rep_>::const_iterator,
19876 typename array<signature_,traits_type_, r_rep_>::const_iterator,
19877 func_type_
19878 > > > result_type;
19879
19880 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "apply<F>(A,A): array sizes do not match");
19881 return result_type(a.begin(), b.begin(), a.size());
19882 }
19883
19884 template<typename func_type_, typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
19885 LITE_INLINE
19886 array<signature_, traits_type_, reference_rep<b_iterator<
19887 typename array<signature_,traits_type_, l_rep_>::iterator,
19888 typename array<signature_,traits_type_, r_rep_>::const_iterator,
19889 func_type_>
19890 > >
19891 apply(array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
19892 {
19893 typedef array<signature_, traits_type_, reference_rep<b_iterator<
19894 typename array<signature_,traits_type_, l_rep_>::iterator,
19895 typename array<signature_,traits_type_, r_rep_>::const_iterator,
19896 func_type_
19897 > > > result_type;
19898
19899 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "apply<F>(A,A): array sizes do not match");
19900 return result_type(a.begin(), b.begin(), a.size());
19901 }
19902
19903 template<typename func_type_, typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
19904 LITE_INLINE
19905 array<signature_, traits_type_, reference_rep<b_iterator<
19906 typename array<signature_,traits_type_, l_rep_>::const_iterator,
19907 typename array<signature_,traits_type_, r_rep_>::iterator,
19908 func_type_>
19909 > >
19910 apply(const array<signature_, traits_type_, l_rep_>& a, array<signature_, traits_type_, r_rep_>& b)
19911 {
19912 typedef array<signature_, traits_type_, reference_rep<b_iterator<
19913 typename array<signature_,traits_type_, l_rep_>::const_iterator,
19914 typename array<signature_,traits_type_, r_rep_>::iterator,
19915 func_type_
19916 > > > result_type;
19917
19918 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "apply<F>(A,A): array sizes do not match");
19919 return result_type(a.begin(), b.begin(), a.size());
19920 }
19921
19922 template<typename func_type_, typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
19923 LITE_INLINE
19924 array<signature_, traits_type_, reference_rep<b_iterator<
19925 typename array<signature_,traits_type_, l_rep_>::iterator,
19926 typename array<signature_,traits_type_, r_rep_>::iterator,
19927 func_type_>
19928 > >
19929 apply(array<signature_, traits_type_, l_rep_>& a, array<signature_, traits_type_, r_rep_>& b)
19930 {
19931 typedef array<signature_, traits_type_, reference_rep<b_iterator<
19932 typename array<signature_,traits_type_, l_rep_>::iterator,
19933 typename array<signature_,traits_type_, r_rep_>::iterator,
19934 func_type_
19935 > > > result_type;
19936
19937 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "apply<F>(A,A): array sizes do not match");
19938 return result_type(a.begin(), b.begin(), a.size());
19939 }
19940
19941
19942
19943
19944
19945 template<typename func_type_, typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
19946 LITE_INLINE
19947 array<signature_, traits_type_, reference_rep<b_iterator<
19948 typename array<signature_,traits_type_, l_rep_>::const_iterator,
19949 typename array<signature_,traits_type_, r_rep_>::const_iterator,
19950 func_type_>
19951 > >
19952 apply(
19953 const array<signature_, traits_type_, l_rep_>& a,
19954 const array<signature_, traits_type_, r_rep_>& b,
19955 const func_type_& func)
19956 {
19957 typedef array<signature_, traits_type_, reference_rep<b_iterator<
19958 typename array<signature_,traits_type_, l_rep_>::const_iterator,
19959 typename array<signature_,traits_type_, r_rep_>::const_iterator,
19960 func_type_,
19961 false
19962 > > > result_type;
19963
19964 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "apply(A,A,f): array sizes do not match");
19965 return result_type(a.begin(), b.begin(), func, a.size());
19966 }
19967
19968 template<typename func_type_, typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
19969 LITE_INLINE
19970 array<signature_, traits_type_, reference_rep<b_iterator<
19971 typename array<signature_,traits_type_, l_rep_>::iterator,
19972 typename array<signature_,traits_type_, r_rep_>::const_iterator,
19973 func_type_>
19974 > >
19975 apply(
19976 array<signature_, traits_type_, l_rep_>& a,
19977 const array<signature_, traits_type_, r_rep_>& b,
19978 const func_type_& func)
19979 {
19980 typedef array<signature_, traits_type_, reference_rep<b_iterator<
19981 typename array<signature_,traits_type_, l_rep_>::iterator,
19982 typename array<signature_,traits_type_, r_rep_>::const_iterator,
19983 func_type_,
19984 false
19985 > > > result_type;
19986
19987 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "apply(A,A,f): array sizes do not match");
19988 return result_type(a.begin(), b.begin(), func, a.size());
19989 }
19990
19991 template<typename func_type_, typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
19992 LITE_INLINE
19993 array<signature_, traits_type_, reference_rep<b_iterator<
19994 typename array<signature_,traits_type_, l_rep_>::const_iterator,
19995 typename array<signature_,traits_type_, r_rep_>::iterator,
19996 func_type_>
19997 > >
19998 apply(
19999 const array<signature_, traits_type_, l_rep_>& a,
20000 array<signature_, traits_type_, r_rep_>& b,
20001 const func_type_& func)
20002 {
20003 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20004 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20005 typename array<signature_,traits_type_, r_rep_>::iterator,
20006 func_type_,
20007 false
20008 > > > result_type;
20009
20010 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "apply(A,A,f): array sizes do not match");
20011 return result_type(a.begin(), b.begin(), func, a.size());
20012 }
20013
20014 template<typename func_type_, typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20015 LITE_INLINE
20016 array<signature_, traits_type_, reference_rep<b_iterator<
20017 typename array<signature_,traits_type_, l_rep_>::iterator,
20018 typename array<signature_,traits_type_, r_rep_>::iterator,
20019 func_type_>
20020 > >
20021 apply(
20022 array<signature_, traits_type_, l_rep_>& a,
20023 array<signature_, traits_type_, r_rep_>& b,
20024 const func_type_& func)
20025 {
20026 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20027 typename array<signature_,traits_type_, l_rep_>::iterator,
20028 typename array<signature_,traits_type_, r_rep_>::iterator,
20029 func_type_,
20030 false
20031 > > > result_type;
20032
20033 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "apply(A,A,f): array sizes do not match");
20034 return result_type(a.begin(), b.begin(), func, a.size());
20035 }
20036
20037
20038
20039
20040
20041 template<typename signature_, typename traits_type_, typename rep_>
20042 LITE_INLINE
20043 array<signature_, traits_type_, reference_rep<u_iterator<
20044 typename array<signature_,traits_type_, rep_>::const_iterator,
20045 uplus<typename array_signature_traits<signature_>::element_type>
20046 > > >
20047 operator+(const array<signature_, traits_type_, rep_>& a)
20048 {
20049 typedef array<signature_, traits_type_, reference_rep<u_iterator<
20050 typename array<signature_,traits_type_, rep_>::const_iterator,
20051 uplus<typename array_signature_traits<signature_>::element_type>
20052 > > > result_type;
20053
20054 return result_type(a.begin(), a.size());
20055 }
20056
20057
20058
20059
20060
20061 template<typename signature_, typename traits_type_, typename rep_>
20062 LITE_INLINE array<signature_, traits_type_, reference_rep<u_iterator<
20063 typename array<signature_,traits_type_, rep_>::const_iterator,
20064 negate<typename array_signature_traits<signature_>::element_type>
20065 > > >
20066 operator-(const array<signature_, traits_type_, rep_>& a)
20067 {
20068 typedef array<signature_, traits_type_, reference_rep<u_iterator<
20069 typename array<signature_,traits_type_, rep_>::const_iterator,
20070 negate<typename array_signature_traits<signature_>::element_type>
20071 > > > result_type;
20072
20073 return result_type(a.begin(), a.size());
20074 }
20075
20076
20077
20078
20079
20080 template<typename signature_, typename traits_type_, typename l_rep_>
20081 LITE_INLINE
20082 array<signature_, traits_type_, reference_rep<b_iterator<
20083 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20084 c_iterator<typename array_signature_traits<signature_>::element_type>,
20085 plus<typename array_signature_traits<signature_>::element_type>
20086 > > >
20087 operator+(
20088 const array<signature_, traits_type_, l_rep_>& a,
20089 const typename array_signature_traits<signature_>::element_type& b)
20090 {
20091 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20092 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20093 c_iterator<typename array_signature_traits<signature_>::element_type>,
20094 plus<typename array_signature_traits<signature_>::element_type>
20095 > > > result_type;
20096
20097 return result_type(a.begin(), b, a.size());
20098 }
20099
20100
20101
20102
20103
20104 template<typename signature_, typename traits_type_, typename r_rep_>
20105 LITE_INLINE
20106 array<signature_, traits_type_, reference_rep<b_iterator<
20107 c_iterator<typename array_signature_traits<signature_>::element_type>,
20108 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20109 plus<typename array_signature_traits<signature_>::element_type>
20110 > > >
20111 operator+(
20112 const typename array_signature_traits<signature_>::element_type& a,
20113 const array<signature_, traits_type_, r_rep_>& b)
20114 {
20115 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20116 c_iterator<typename array_signature_traits<signature_>::element_type>,
20117 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20118 plus<typename array_signature_traits<signature_>::element_type>
20119 > > > result_type;
20120
20121 return result_type(a, b.begin(), b.size());
20122 }
20123
20124
20125
20126
20127
20128 template<typename signature_, typename traits_type_, typename l_rep_>
20129 LITE_INLINE
20130 array<signature_, traits_type_, reference_rep<b_iterator<
20131 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20132 c_iterator<typename array_signature_traits<signature_>::element_type>,
20133 minus<typename array_signature_traits<signature_>::element_type>
20134 > > >
20135 operator-(
20136 const array<signature_, traits_type_, l_rep_>& a,
20137 const typename array_signature_traits<signature_>::element_type& b)
20138 {
20139 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20140 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20141 c_iterator<typename array_signature_traits<signature_>::element_type>,
20142 minus<typename array_signature_traits<signature_>::element_type>
20143 > > > result_type;
20144
20145 return result_type(a.begin(), b, a.size());
20146 }
20147
20148
20149
20150
20151
20152 template<typename signature_, typename traits_type_, typename r_rep_>
20153 LITE_INLINE
20154 array<signature_, traits_type_, reference_rep<b_iterator<
20155 c_iterator<typename array_signature_traits<signature_>::element_type>,
20156 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20157 minus<typename array_signature_traits<signature_>::element_type>
20158 > > >
20159 operator-(
20160 const typename array_signature_traits<signature_>::element_type& a,
20161 const array<signature_, traits_type_, r_rep_>& b)
20162 {
20163 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20164 c_iterator<typename array_signature_traits<signature_>::element_type>,
20165 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20166 minus<typename array_signature_traits<signature_>::element_type>
20167 > > > result_type;
20168
20169 return result_type(a, b.begin(), b.size());
20170 }
20171
20172
20173
20174
20175
20176
20177 template<typename signature_, typename traits_type_, typename l_rep_>
20178 LITE_INLINE
20179 array<signature_, traits_type_, reference_rep<b_iterator<
20180 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20181 c_iterator<typename array_signature_traits<signature_>::element_type>,
20182 multiplies<typename array_signature_traits<signature_>::element_type>
20183 > > >
20184 operator*(
20185 const array<signature_, traits_type_, l_rep_>& a,
20186 const typename array_signature_traits<signature_>::element_type& b)
20187 {
20188 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20189 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20190 c_iterator<typename array_signature_traits<signature_>::element_type>,
20191 multiplies<typename array_signature_traits<signature_>::element_type>
20192 > > > result_type;
20193
20194 return result_type(a.begin(), b, a.size());
20195 }
20196
20197
20198
20199
20200
20201 template<typename signature_, typename traits_type_, typename r_rep_>
20202 LITE_INLINE
20203 array<signature_, traits_type_, reference_rep<b_iterator<
20204 c_iterator<typename array_signature_traits<signature_>::element_type>,
20205 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20206 multiplies<typename array_signature_traits<signature_>::element_type>
20207 > > >
20208 operator*(
20209 const typename array_signature_traits<signature_>::element_type& a,
20210 const array<signature_, traits_type_, r_rep_>& b)
20211 {
20212 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20213 c_iterator<typename array_signature_traits<signature_>::element_type>,
20214 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20215 multiplies<typename array_signature_traits<signature_>::element_type>
20216 > > > result_type;
20217
20218 return result_type(a, b.begin(), b.size());
20219 }
20220
20221
20222
20223
20224
20225 template<typename signature_, typename traits_type_, typename l_rep_>
20226 LITE_INLINE
20227 array<signature_, traits_type_, reference_rep<b_iterator<
20228 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20229 c_iterator<typename array_signature_traits<signature_>::element_type>,
20230 divides<typename array_signature_traits<signature_>::element_type>
20231 > > >
20232 operator/(
20233 const array<signature_, traits_type_, l_rep_>& a,
20234 const typename array_signature_traits<signature_>::element_type& b)
20235 {
20236 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20237 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20238 c_iterator<typename array_signature_traits<signature_>::element_type>,
20239 divides<typename array_signature_traits<signature_>::element_type>
20240 > > > result_type;
20241
20242 return result_type(a.begin(), b, a.size());
20243 }
20244
20245
20246
20247
20248
20249
20250 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20251 LITE_INLINE
20252 array<signature_, traits_type_, reference_rep<b_iterator<
20253 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20254 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20255 plus<typename array_signature_traits<signature_>::element_type>
20256 > > >
20257 operator+(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20258 {
20259 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20260 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20261 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20262 plus<typename array_signature_traits<signature_>::element_type>
20263 > > > result_type;
20264
20265 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator+(A,A): array sizes do not match");
20266 return result_type(a.begin(), b.begin(), a.size());
20267 }
20268
20269
20270
20271
20272
20273 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20274 LITE_INLINE
20275 array<signature_, traits_type_, reference_rep<b_iterator<
20276 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20277 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20278 minus<typename array_signature_traits<signature_>::element_type>
20279 > > >
20280 operator-(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20281 {
20282 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20283 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20284 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20285 minus<typename array_signature_traits<signature_>::element_type>
20286 > > > result_type;
20287
20288 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator-(A,A): array sizes do not match");
20289 return result_type(a.begin(), b.begin(), a.size());
20290 }
20291
20292
20293
20294
20295
20296 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20297 LITE_INLINE
20298 array<signature_, traits_type_, reference_rep<b_iterator<
20299 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20300 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20301 multiplies<typename array_signature_traits<signature_>::element_type>
20302 > > >
20303 operator|(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20304 {
20305 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20306 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20307 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20308 multiplies<typename array_signature_traits<signature_>::element_type>
20309 > > > result_type;
20310
20311 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator|(A,A): array sizes do not match");
20312 return result_type(a.begin(), b.begin(), a.size());
20313 }
20314
20315
20316
20317
20318
20319 template<typename signature_, typename traits_type_, typename l_rep_>
20320 LITE_INLINE
20321 const array<signature_, traits_type_, l_rep_>&
20322 operator+=(
20323 const array<signature_, traits_type_, l_rep_>& a,
20324 const typename array_signature_traits<signature_>::element_type& b)
20325 {
20326 typedef b_iterator<
20327 typename array<signature_,traits_type_, l_rep_>::iterator,
20328 c_iterator<typename array_signature_traits<signature_>::element_type>,
20329 plus_assign<typename array_signature_traits<signature_>::element_type>
20330 > iterator_type;
20331
20332 for_each(iterator_type(a.begin(), b), a.size());
20333 return a;
20334 }
20335
20336 template<typename signature_, typename traits_type_, typename l_rep_>
20337 LITE_INLINE
20338 array<signature_, traits_type_, l_rep_>&
20339 operator+=(
20340 array<signature_, traits_type_, l_rep_>& a,
20341 const typename array_signature_traits<signature_>::element_type& b)
20342 {
20343 typedef b_iterator<
20344 typename array<signature_,traits_type_, l_rep_>::iterator,
20345 c_iterator<typename array_signature_traits<signature_>::element_type>,
20346 plus_assign<typename array_signature_traits<signature_>::element_type>
20347 > iterator_type;
20348
20349 for_each(iterator_type(a.begin(), b), a.size());
20350 return a;
20351 }
20352
20353
20354
20355
20356
20357 template<typename signature_, typename traits_type_, typename l_rep_>
20358 LITE_INLINE
20359 const array<signature_, traits_type_, l_rep_>&
20360 operator-=(
20361 const array<signature_, traits_type_, l_rep_>& a,
20362 const typename array_signature_traits<signature_>::element_type& b)
20363 {
20364 typedef b_iterator<
20365 typename array<signature_,traits_type_, l_rep_>::iterator,
20366 c_iterator<typename array_signature_traits<signature_>::element_type>,
20367 minus_assign<typename array_signature_traits<signature_>::element_type>
20368 > iterator_type;
20369
20370 for_each(iterator_type(a.begin(), b), a.size());
20371 return a;
20372 }
20373
20374 template<typename signature_, typename traits_type_, typename l_rep_>
20375 LITE_INLINE
20376 array<signature_, traits_type_, l_rep_>&
20377 operator-=(
20378 array<signature_, traits_type_, l_rep_>& a,
20379 const typename array_signature_traits<signature_>::element_type& b)
20380 {
20381 typedef b_iterator<
20382 typename array<signature_,traits_type_, l_rep_>::iterator,
20383 c_iterator<typename array_signature_traits<signature_>::element_type>,
20384 minus_assign<typename array_signature_traits<signature_>::element_type>
20385 > iterator_type;
20386
20387 for_each(iterator_type(a.begin(), b), a.size());
20388 return a;
20389 }
20390
20391
20392
20393
20394
20395 template<typename signature_, typename traits_type_, typename l_rep_>
20396 LITE_INLINE
20397 const array<signature_, traits_type_, l_rep_>&
20398 operator*=(
20399 const array<signature_, traits_type_, l_rep_>& a,
20400 const typename array_signature_traits<signature_>::element_type& b)
20401 {
20402 typedef b_iterator<
20403 typename array<signature_,traits_type_, l_rep_>::iterator,
20404 c_iterator<typename array_signature_traits<signature_>::element_type>,
20405 multiplies_assign<typename array_signature_traits<signature_>::element_type>
20406 > iterator_type;
20407
20408 for_each(iterator_type(a.begin(), b), a.size());
20409 return a;
20410 }
20411
20412 template<typename signature_, typename traits_type_, typename l_rep_>
20413 LITE_INLINE
20414 array<signature_, traits_type_, l_rep_>&
20415 operator*=(
20416 array<signature_, traits_type_, l_rep_>& a,
20417 const typename array_signature_traits<signature_>::element_type& b)
20418 {
20419 typedef b_iterator<
20420 typename array<signature_,traits_type_, l_rep_>::iterator,
20421 c_iterator<typename array_signature_traits<signature_>::element_type>,
20422 multiplies_assign<typename array_signature_traits<signature_>::element_type>
20423 > iterator_type;
20424
20425 for_each(iterator_type(a.begin(), b), a.size());
20426 return a;
20427 }
20428
20429
20430
20431
20432
20433 template<typename signature_, typename traits_type_, typename l_rep_>
20434 LITE_INLINE
20435 const array<signature_, traits_type_, l_rep_>&
20436 operator/=(
20437 const array<signature_, traits_type_, l_rep_>& a,
20438 const typename array_signature_traits<signature_>::element_type& b)
20439 {
20440 typedef b_iterator<
20441 typename array<signature_,traits_type_, l_rep_>::iterator,
20442 c_iterator<typename array_signature_traits<signature_>::element_type>,
20443 divides_assign<typename array_signature_traits<signature_>::element_type>
20444 > iterator_type;
20445
20446 for_each(iterator_type(a.begin(), b), a.size());
20447 return a;
20448 }
20449
20450 template<typename signature_, typename traits_type_, typename l_rep_>
20451 LITE_INLINE
20452 array<signature_, traits_type_, l_rep_>&
20453 operator/=(
20454 array<signature_, traits_type_, l_rep_>& a,
20455 const typename array_signature_traits<signature_>::element_type& b)
20456 {
20457 typedef b_iterator<
20458 typename array<signature_,traits_type_, l_rep_>::iterator,
20459 c_iterator<typename array_signature_traits<signature_>::element_type>,
20460 divides_assign<typename array_signature_traits<signature_>::element_type>
20461 > iterator_type;
20462
20463 for_each(iterator_type(a.begin(), b), a.size());
20464 return a;
20465 }
20466
20467
20468
20469
20470
20471 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20472 LITE_INLINE
20473 array<signature_, traits_type_, l_rep_>&
20474 operator+=(array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20475 {
20476 typedef b_iterator<
20477 typename array<signature_,traits_type_, l_rep_>::iterator,
20478 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20479 plus_assign<typename array_signature_traits<signature_>::element_type>
20480 > iterator_type;
20481
20482 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator+=(A,A): array sizes do not match");
20483 for_each(iterator_type(a.begin(), b.begin()), a.size());
20484 return a;
20485 }
20486
20487 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20488 LITE_INLINE
20489 const array<signature_, traits_type_, l_rep_>&
20490 operator+=(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20491 {
20492 typedef b_iterator<
20493 typename array<signature_,traits_type_, l_rep_>::iterator,
20494 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20495 plus_assign<typename array_signature_traits<signature_>::element_type>
20496 > iterator_type;
20497
20498 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator+=(A,A): array sizes do not match");
20499 for_each(iterator_type(a.begin(), b.begin()), a.size());
20500 return a;
20501 }
20502
20503
20504
20505
20506
20507 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20508 LITE_INLINE
20509 array<signature_, traits_type_, l_rep_>&
20510 operator-=(array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20511 {
20512 typedef b_iterator<
20513 typename array<signature_,traits_type_, l_rep_>::iterator,
20514 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20515 minus_assign<typename array_signature_traits<signature_>::element_type>
20516 > iterator_type;
20517
20518 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator-=(A,A): array sizes do not match");
20519 for_each(iterator_type(a.begin(), b.begin()), a.size());
20520 return a;
20521 }
20522
20523 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20524 LITE_INLINE
20525 const array<signature_, traits_type_, l_rep_>&
20526 operator-=(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20527 {
20528 typedef b_iterator<
20529 typename array<signature_,traits_type_, l_rep_>::iterator,
20530 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20531 minus_assign<typename array_signature_traits<signature_>::element_type>
20532 > iterator_type;
20533
20534 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator-=(A,A): array sizes do not match");
20535 for_each(iterator_type(a.begin(), b.begin()), a.size());
20536 return a;
20537 }
20538
20539
20540
20541
20542
20543 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20544 LITE_INLINE
20545 array<signature_, traits_type_, l_rep_>&
20546 operator|=(array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20547 {
20548 typedef b_iterator<
20549 typename array<signature_,traits_type_, l_rep_>::iterator,
20550 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20551 multiplies_assign<typename array_signature_traits<signature_>::element_type>
20552 > iterator_type;
20553
20554 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator|=(A,A): array sizes do not match");
20555 for_each(iterator_type(a.begin(), b.begin()), a.size());
20556 return a;
20557 }
20558
20559 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20560 LITE_INLINE
20561 const array<signature_, traits_type_, l_rep_>&
20562 operator|=(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20563 {
20564 typedef b_iterator<
20565 typename array<signature_,traits_type_, l_rep_>::iterator,
20566 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20567 multiplies_assign<typename array_signature_traits<signature_>::element_type>
20568 > iterator_type;
20569
20570 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator|=(A,A): array sizes do not match");
20571 for_each(iterator_type(a.begin(), b.begin()), a.size());
20572 return a;
20573 }
20574
20575
20576
20577
20578
20579 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20580 LITE_INLINE bool
20581 operator<(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20582 {
20583 typedef b_iterator<
20584 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20585 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20586 less<typename array_signature_traits<signature_>::element_type>
20587 > iterator_type;
20588
20589 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator<(A,A): array sizes do not match");
20590 return for_each_c(iterator_type(a.begin(), b.begin()), a.size());
20591 }
20592
20593
20594
20595
20596
20597 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20598 LITE_INLINE bool
20599 operator<=(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20600 {
20601 typedef b_iterator<
20602 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20603 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20604 less_equal<typename array_signature_traits<signature_>::element_type>
20605 > iterator_type;
20606
20607 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator<=(A,A): array sizes do not match");
20608 return for_each_c(iterator_type(a.begin(), b.begin()), a.size());
20609 }
20610
20611
20612
20613
20614
20615 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20616 LITE_INLINE bool
20617 operator==(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20618 {
20619 typedef b_iterator<
20620 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20621 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20622 equal_to<typename array_signature_traits<signature_>::element_type>
20623 > iterator_type;
20624
20625 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator==(A,A): array sizes do not match");
20626 return for_each_c(iterator_type(a.begin(), b.begin()), a.size());
20627 }
20628
20629
20630
20631
20632
20633 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20634 LITE_INLINE bool
20635 operator!=(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20636 {
20637 return !(a==b);
20638 }
20639
20640
20641
20642
20643
20644 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20645 LITE_INLINE bool
20646 operator>=(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20647 {
20648 typedef b_iterator<
20649 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20650 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20651 greater_equal<typename array_signature_traits<signature_>::element_type>
20652 > iterator_type;
20653
20654 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator>=(A,A): array sizes do not match");
20655 return for_each_c(iterator_type(a.begin(), b.begin()), a.size());
20656 }
20657
20658
20659
20660
20661
20662 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20663 LITE_INLINE bool
20664 operator>(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20665 {
20666 typedef b_iterator<
20667 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20668 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20669 greater<typename array_signature_traits<signature_>::element_type>
20670 > iterator_type;
20671
20672 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator>(A,A): array sizes do not match");
20673 return for_each_c(iterator_type(a.begin(), b.begin()), a.size());
20674 }
20675
20676
20677
20678
20679
20680 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20681 LITE_INLINE int
20682 compare(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20683 {
20684 typedef b_iterator<
20685 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20686 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20687 compare3<typename array_signature_traits<signature_>::element_type>
20688 > iterator_type;
20689
20690 while_equal<typename compare3<
20691 typename array_signature_traits<signature_>::element_type>::result_type> func;
20692
20693 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "compare(A,A): array sizes do not match");
20694 for_each_c(iterator_type(a.begin(), b.begin()), func, a.size());
20695 return func();
20696 }
20697
20698
20699
20700
20701
20702 template<typename signature_, typename traits_type_, typename rep_>
20703 LITE_INLINE typename array_signature_traits<signature_>::element_type
20704 norm(const array<signature_, traits_type_, rep_>& a)
20705 {
20706 typedef u_iterator<
20707 typename array<signature_,traits_type_, rep_>::const_iterator,
20708 square<typename array_signature_traits<signature_>::element_type>
20709 > iterator_type;
20710
20711 accumulator<typename array_signature_traits<signature_>::element_type> acc;
20712
20713 for_each(iterator_type(a.begin()), acc, a.size());
20714 return acc();
20715 }
20716
20717
20718
20719
20720
20721 template<typename signature_, typename traits_type_, typename rep_>
20722 LITE_INLINE const typename array_helper<signature_, traits_type_>::temporary_array
20723 normalized(const array<signature_, traits_type_, rep_>& a)
20724 {
20725 typedef array<signature_, traits_type_, rep_> a_type;
20726 typedef typename array_helper<signature_, traits_type_>::temporary_array result_type;
20727 typedef typename array_signature_traits<signature_>::element_type value_type;
20728 typedef u_iterator<typename result_type::iterator, square<value_type> > iterator_type;
20729
20730 result_type result = a;
20731 accumulator<value_type> acc;
20732
20733 for_each(iterator_type(result.begin()), acc, result.size());
20734 result *= value_type(1)/sqrt(acc());
20735 return result;
20736 }
20737
20738
20739
20740
20741
20742 template<typename signature_, typename traits_type_, typename rep_>
20743 LITE_INLINE typename array_signature_traits<signature_>::element_type
20744 abs(const array<signature_, traits_type_, rep_>& a)
20745 {
20746 return sqrt(norm(a));
20747 }
20748
20749
20750
20751
20752
20753 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20754 LITE_INLINE
20755 array<signature_, traits_type_, reference_rep<b_iterator<
20756 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20757 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20758 minimum<typename array_signature_traits<signature_>::element_type>
20759 > > >
20760 min(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20761 {
20762 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20763 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20764 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20765 minimum<typename array_signature_traits<signature_>::element_type>
20766 > > > result_type;
20767
20768 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "min(A,A): array sizes do not match");
20769
20770 return result_type(a.begin(), b.begin(), a.size());
20771 }
20772
20773 template<typename signature_, typename traits_type_, typename rep_>
20774 LITE_INLINE
20775 array<signature_, traits_type_, reference_rep<b_iterator<
20776 typename array<signature_,traits_type_, rep_>::const_iterator,
20777 typename array<signature_,traits_type_, rep_>::const_iterator,
20778 minimum<typename array_signature_traits<signature_>::element_type>
20779 > > >
20780 min(const array<signature_, traits_type_, rep_>& a, const array<signature_, traits_type_, rep_>& b)
20781 {
20782 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20783 typename array<signature_,traits_type_, rep_>::const_iterator,
20784 typename array<signature_,traits_type_, rep_>::const_iterator,
20785 minimum<typename array_signature_traits<signature_>::element_type>
20786 > > > result_type;
20787
20788 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "min(A,A): array sizes do not match");
20789
20790 return result_type(a.begin(), b.begin(), a.size());
20791 }
20792
20793
20794
20795
20796
20797 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
20798 LITE_INLINE
20799 array<signature_, traits_type_, reference_rep<b_iterator<
20800 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20801 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20802 maximum<typename array_signature_traits<signature_>::element_type>
20803 > > >
20804 max(const array<signature_, traits_type_, l_rep_>& a, const array<signature_, traits_type_, r_rep_>& b)
20805 {
20806 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20807 typename array<signature_,traits_type_, l_rep_>::const_iterator,
20808 typename array<signature_,traits_type_, r_rep_>::const_iterator,
20809 maximum<typename array_signature_traits<signature_>::element_type>
20810 > > > result_type;
20811
20812 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "max(A,A): array sizes do not match");
20813
20814 return result_type(a.begin(), b.begin(), a.size());
20815 }
20816
20817 template<typename signature_, typename traits_type_, typename rep_>
20818 LITE_INLINE
20819 array<signature_, traits_type_, reference_rep<b_iterator<
20820 typename array<signature_,traits_type_, rep_>::const_iterator,
20821 typename array<signature_,traits_type_, rep_>::const_iterator,
20822 maximum<typename array_signature_traits<signature_>::element_type>
20823 > > >
20824 max(const array<signature_, traits_type_, rep_>& a, const array<signature_, traits_type_, rep_>& b)
20825 {
20826 typedef array<signature_, traits_type_, reference_rep<b_iterator<
20827 typename array<signature_,traits_type_, rep_>::const_iterator,
20828 typename array<signature_,traits_type_, rep_>::const_iterator,
20829 maximum<typename array_signature_traits<signature_>::element_type>
20830 > > > result_type;
20831
20832 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "max(A,A): array sizes do not match");
20833
20834 return result_type(a.begin(), b.begin(), a.size());
20835 }
20836
20837
20838
20839
20840
20841 template<typename value_type_, int n_, typename traits_type_, typename l_rep_, typename r_rep_>
20842 LITE_INLINE
20843 typename detail::enable_if<(array_signature_traits<value_type_>::dimensions == 0), value_type_>::type
20844 operator*(
20845 const array<value_type_[n_], traits_type_, l_rep_>& a,
20846 const array<value_type_[n_], traits_type_, r_rep_>& b)
20847 {
20848 typedef b_iterator<
20849 typename array<value_type_[n_],traits_type_, l_rep_>::const_iterator,
20850 typename array<value_type_[n_],traits_type_, r_rep_>::const_iterator,
20851 multiplies<value_type_>
20852 > iterator_type;
20853
20854 accumulator<value_type_> acc;
20855
20856 LITE_ARRAY_SIZE_CHECK(a.size(), b.size(), "operator*(V,V): vector sizes do not match");
20857 for_each(iterator_type(a.begin(), b.begin()), acc, a.size());
20858 return acc();
20859 }
20860
20861
20862
20863
20864
20865 template<typename value_type_, int m_, int n_, typename traits_type_, typename l_rep_, typename r_rep_>
20866 LITE_INLINE
20867 typename detail::enable_if<
20868 (array_signature_traits<value_type_>::dimensions == 0),
20869 const typename array_helper<value_type_[m_], traits_type_>::temporary_array
20870 >::type
20871 operator*(
20872 const array<value_type_[m_][n_], traits_type_, l_rep_>& a,
20873 const array<value_type_[n_], traits_type_, r_rep_>& b)
20874 {
20875 typedef array<value_type_[m_][n_], traits_type_, l_rep_> a_type;
20876 typedef array<value_type_[n_], traits_type_, r_rep_> b_type;
20877 typedef typename array_helper<value_type_[m_], traits_type_>::temporary_array result_type;
20878 typedef typename result_type::size_type size_type;
20879
20880 typename detail::matrix_policy<a_type, 1> ::cached_fwd_array aa = a;
20881 typename detail::matrix_policy<b_type, 9> ::cached_array bb = b;
20882
20883 const int m = aa.size().i0;
20884
20885 const size_type size(m);
20886 result_type result(size);
20887
20888 LITE_ARRAY_SIZE_CHECK(aa.size().i1, b.size().i0, "operator*(M,V): matrix/vector sizes do not match");
20889
20890 for (int i=0; i<m; i++)
20891 result[i] = aa[row(i)]*bb;
20892
20893 return result;
20894 }
20895
20896
20897
20898
20899
20900 template<typename value_type_, int m_, int n_, typename traits_type_, typename l_rep_, typename r_rep_>
20901 LITE_INLINE
20902 typename detail::enable_if<
20903 (array_signature_traits<value_type_>::dimensions == 0),
20904 const typename array_helper<value_type_[n_], traits_type_>::temporary_array
20905 >::type
20906 operator*(
20907 const array<value_type_[m_], traits_type_, l_rep_>& a,
20908 const array<value_type_[m_][n_], traits_type_, r_rep_>& b)
20909 {
20910 typedef array<value_type_[m_], traits_type_, l_rep_> a_type;
20911 typedef array<value_type_[m_][n_], traits_type_, r_rep_> b_type;
20912 typedef typename array_helper<value_type_[n_], traits_type_>::temporary_array result_type;
20913 typedef typename result_type::size_type size_type;
20914
20915 typename detail::matrix_policy<a_type, 9>::cached_array aa = a;
20916 typename detail::matrix_policy<b_type, 1>::cached_rev_array bb = b;
20917
20918 const int n = bb.size().i1;
20919
20920 const size_type size(n);
20921 result_type result(size);
20922
20923 LITE_ARRAY_SIZE_CHECK(aa.size().i0, bb.size().i0, "operator*(V,M): matrix/vector sizes do not match");
20924
20925 for (int j=0; j<n; j++)
20926 result[j] = aa*bb[column(j)];
20927
20928 return result;
20929 }
20930
20931
20932
20933
20934
20935 template<
20936 typename value_type_,
20937 int m_,
20938 int n_,
20939 int p_,
20940 typename traits_type_,
20941 typename l_rep_,
20942 typename r_rep_>
20943 LITE_INLINE
20944 typename detail::enable_if<
20945 (array_signature_traits<value_type_>::dimensions == 0),
20946 const typename array_helper<value_type_[m_][p_], traits_type_>::temporary_array
20947 >::type
20948 operator*(
20949 const array<value_type_[m_][n_], traits_type_, l_rep_>& a,
20950 const array<value_type_[n_][p_], traits_type_, r_rep_>& b)
20951 {
20952 typedef array<value_type_[m_][n_], traits_type_, l_rep_> a_type;
20953 typedef array<value_type_[n_][p_], traits_type_, r_rep_> b_type;
20954 typedef typename array_helper<value_type_[m_][p_], traits_type_>::temporary_array result_type;
20955 typedef typename result_type::size_type size_type;
20956
20957 typename detail::matrix_policy<a_type, 9>::cached_fwd_array aa = a;
20958 typename detail::matrix_policy<b_type, 9>::cached_rev_array bb = b;
20959
20960 const int m = aa.size().i0;
20961 const int p = bb.size().i1;
20962
20963 const size_type size(m, p);
20964 result_type result(size);
20965
20966 LITE_ARRAY_SIZE_CHECK(aa.size().i1, bb.size().i0, "operator*(M,M): matrix sizes do not match");
20967
20968 for (int i=0; i<m; i++)
20969 for (int j=0; j<p; j++)
20970 result(i,j) = aa[row(i)]*bb[column(j)];
20971
20972 return result;
20973 }
20974
20975
20976
20977
20978
20979 template<typename value_type_, typename traits_type_, typename l_rep_, typename r_rep_>
20980 LITE_INLINE
20981 typename detail::enable_if<(
20982 array_signature_traits<value_type_>::dimensions == 0),
20983 value_type_
20984 >::type
20985 operator%(
20986 const array<value_type_[2], traits_type_, l_rep_>& a,
20987 const array<value_type_[2], traits_type_, r_rep_>& b)
20988 {
20989 return a[0]*b[1]-a[1]*b[0];
20990 }
20991
20992
20993
20994
20995
20996 template<typename value_type_, typename traits_type_, typename l_rep_, typename r_rep_>
20997 LITE_INLINE
20998 typename detail::enable_if<(
20999 array_signature_traits<value_type_>::dimensions == 0),
21000 const typename array_helper<value_type_[3], traits_type_>::temporary_array
21001 >::type
21002 operator%(
21003 const array<value_type_[3], traits_type_, l_rep_>& a,
21004 const array<value_type_[3], traits_type_, r_rep_>& b)
21005 {
21006 typedef array<value_type_[3], traits_type_, l_rep_> a_type;
21007 typedef array<value_type_[3], traits_type_, r_rep_> b_type;
21008 typedef typename array_helper<value_type_[3], traits_type_>::temporary_array result_type;
21009
21010 typename detail::matrix_policy<a_type, 9>::cached_array aa = a;
21011 typename detail::matrix_policy<b_type, 9>::cached_array bb = b;
21012
21013 return result_type(aa[1]*bb[2]-aa[2]*bb[1], aa[2]*bb[0]-aa[0]*bb[2], aa[0]*bb[1]-aa[1]*bb[0]);
21014 }
21015
21016
21017
21018
21019
21020 template<typename value_type_, typename traits_type_, typename rep_>
21021 LITE_INLINE
21022 typename detail::enable_if<(
21023 array_signature_traits<value_type_>::dimensions == 0),
21024 value_type_
21025 >::type
21026 det(const array<value_type_[2][2], traits_type_, rep_>& a)
21027 {
21028 return a(0, 0)*a(1, 1) - a(0, 1)*a(1, 0);
21029 }
21030
21031
21032
21033
21034
21035 template<typename value_type_, typename traits_type_, typename rep_>
21036 LITE_INLINE
21037 typename detail::enable_if<(
21038 array_signature_traits<value_type_>::dimensions == 0),
21039 value_type_
21040 >::type
21041 det(const array<value_type_[3][3], traits_type_, rep_>& a)
21042 {
21043 typedef array<value_type_[3][3], traits_type_, rep_> a_type;
21044 typename detail::matrix_policy<a_type, 9>::cached_fwd_array aa = a;
21045
21046 value_type_ det00 = aa(2, 2)*aa(1, 1)-aa(2, 1)*aa(1, 2);
21047 value_type_ det10 = aa(2, 2)*aa(0, 1)-aa(2, 1)*aa(0, 2);
21048 value_type_ det20 = aa(1, 2)*aa(0, 1)-aa(1, 1)*aa(0, 2);
21049 return aa(0, 0)*det00-aa(1, 0)*det10+aa(2, 0)*det20;
21050 }
21051
21052
21053
21054
21055
21056
21057 template<typename value_type_, int n_, typename traits_type_, typename rep_>
21058 LITE_INLINE
21059 typename detail::enable_if<(
21060 array_signature_traits<value_type_>::dimensions == 0),
21061 value_type_
21062 >::type
21063 det(const array<value_type_[n_][n_], traits_type_, rep_>& a)
21064 {
21065 using std::abs;
21066
21067 typedef typename array_helper<value_type_[n_][n_], traits_type_>::fwd_temporary_array temporary_type;
21068 typedef array<value_type_[n_][n_], traits_type_, rep_> a_type;
21069
21070 LITE_ARRAY_SIZE_CHECK(a.size().i0, a.size().i1, "det(M): not a square matrix");
21071
21072 temporary_type aa = a;
21073 const int n = aa.size().i0;
21074 int swaps = 0;
21075
21076 for (int i=0; i<n; i++) {
21077 const block<0,1> blk(0, n-i);
21078 int i_max = i;
21079 value_type_ val_max = abs(aa(i, i));
21080
21081
21082 for (int i2 = i+1; i2<n; i2++)
21083 if (abs(aa(i2, i)) > val_max) {
21084 i_max = i2;
21085 val_max = abs(aa(i2, i));
21086 }
21087
21088
21089 if (i_max != i) {
21090 typename transform_traits<temporary_type, block<0,1> >::temporary_array tmp_row;
21091
21092 tmp_row = aa[blk(i, i)];
21093 aa[blk(i, i)] = aa[blk(i_max, i)];
21094 aa[blk(i_max, i)] = tmp_row;
21095 swaps++;
21096 }
21097
21098
21099 if (aa(i, i) == value_type_())
21100 return value_type_();
21101
21102 value_type_ epsilon = std::numeric_limits<value_type_>::epsilon()*aa(i, i)*n;
21103 value_type_ factor = value_type_(1)/aa(i, i);
21104
21105
21106 for (int i2 = i+1; i2<n; i2++)
21107 if (abs(aa(i2, i)) > epsilon)
21108 aa[blk(i2, i)] -= (aa(i2, i)*factor)*aa[blk(i, i)];
21109 }
21110
21111 value_type_ result = value_type_(1);
21112
21113 for (int i=0; i<n; i++)
21114 result *= aa(i, i);
21115
21116 return (swaps & 1) != 0 ? -result : result;
21117 }
21118
21119
21120
21121
21122
21123 template<typename value_type_, typename traits_type_, typename rep_>
21124 LITE_INLINE
21125 typename detail::enable_if<(
21126 array_signature_traits<value_type_>::dimensions == 0),
21127 const typename array_helper<value_type_[2][2], traits_type_>::temporary_array
21128 >::type
21129 inverse(const array<value_type_[2][2], traits_type_, rep_>& a)
21130 {
21131 typedef array<value_type_[2][2], traits_type_, rep_> a_type;
21132 typename detail::matrix_policy<a_type, 9>::cached_fwd_array aa = a;
21133
21134 typename array_helper<value_type_[2][2], traits_type_>::temporary_array result;
21135
21136 value_type_ inv_det = value_type_(1)/(aa(0, 0)*aa(1, 1) - aa(0, 1)*a(1, 0));
21137
21138 result(0, 0) = aa(1, 1) * inv_det;
21139 result(0, 1) = -aa(0, 1) * inv_det;
21140 result(0, 2) = -aa(1, 0) * inv_det;
21141 result(0, 3) = aa(0, 0) * inv_det;
21142
21143 return result;
21144 }
21145
21146
21147
21148
21149
21150 template<typename value_type_, typename traits_type_, typename rep_>
21151 LITE_INLINE
21152 typename detail::enable_if<(
21153 array_signature_traits<value_type_>::dimensions == 0),
21154 const typename array_helper<value_type_[3][3], traits_type_>::temporary_array
21155 >::type
21156 inverse(const array<value_type_[3][3], traits_type_, rep_>& a)
21157 {
21158 typedef array<value_type_[3][3], traits_type_, rep_> a_type;
21159 typename detail::matrix_policy<a_type, 9>::cached_fwd_array aa = a;
21160
21161 typename array_helper<value_type_[3][3], traits_type_>::temporary_array result;
21162
21163 value_type_ det00 = aa(2, 2)*aa(1, 1)-aa(2, 1)*aa(1, 2);
21164 value_type_ det10 = aa(2, 2)*aa(0, 1)-aa(2, 1)*aa(0, 2);
21165 value_type_ det20 = aa(1, 2)*aa(0, 1)-aa(1, 1)*aa(0, 2);
21166 value_type_ inv_det = value_type_(1)/(aa(0, 0)*det00-aa(1, 0)*det10+aa(2, 0)*det20);
21167
21168 result(0, 0) = det00*inv_det;
21169 result(0, 1) = -det10*inv_det;
21170 result(0, 2) = det20*inv_det;
21171 result(1, 0) = (aa(2, 0)*aa(1, 2)-aa(2, 2)*aa(1, 0))*inv_det;
21172 result(1, 1) = (aa(2, 2)*aa(0, 0)-aa(2, 0)*aa(0, 2))*inv_det;
21173 result(1, 2) = (aa(1, 0)*aa(0, 2)-aa(1, 2)*aa(0, 0))*inv_det;
21174 result(2, 0) = (aa(2, 1)*aa(1, 0)-aa(2, 0)*aa(1, 1))*inv_det;
21175 result(2, 1) = (aa(2, 0)*aa(0, 1)-aa(2, 1)*aa(0, 0))*inv_det;
21176 result(2, 2) = (aa(1, 1)*aa(0, 0)-aa(1, 0)*aa(0, 1))*inv_det;
21177
21178 return result;
21179 }
21180
21181
21182
21183
21184
21185
21186 template<typename value_type_, int n_, typename traits_type_, typename rep_>
21187 LITE_INLINE
21188 typename detail::enable_if<(
21189 array_signature_traits<value_type_>::dimensions == 0),
21190 const typename array_helper<value_type_[n_][n_], traits_type_>::temporary_array
21191 >::type
21192 inverse(const array<value_type_[n_][n_], traits_type_, rep_>& a)
21193 {
21194 using std::abs;
21195
21196 typedef array<value_type_[n_][n_], traits_type_, rep_> a_type;
21197 typedef typename array_helper<value_type_[n_][n_], traits_type_>::temporary_array temporary_type;
21198
21199 LITE_ARRAY_SIZE_CHECK(a.size().i0, a.size().i1, "inverse(M): not a square matrix");
21200
21201 const int n = a.size().i0;
21202 temporary_type aa=a, result(n, n);
21203
21204 result = value_type_();
21205
21206 result[diagonal()] = value_type_(1);
21207
21208 for (int i=0; i<n; i++) {
21209 const block<0,1> blk(0, n-i);
21210 int i_max = i;
21211 value_type_ val_max = abs(aa(i, i));
21212
21213
21214 for (int i2 = i+1; i2<n; i2++)
21215 if (abs(aa(i2, i)) > val_max) {
21216 i_max = i2;
21217 val_max = abs(aa(i2, i));
21218 }
21219
21220
21221 if (i_max != i) {
21222 typename transform_traits<temporary_type, row>::temporary_array res_tmp;
21223
21224 res_tmp = result[row(i)];
21225 result[row(i)] = result[row(i_max)];
21226 result[row(i_max)] = res_tmp;
21227
21228 typename transform_traits<temporary_type, block<0,1> >::temporary_array org_tmp;
21229
21230 org_tmp = aa[blk(i,i)];
21231 aa[blk(i,i)] = aa[blk(i_max, i)];
21232 aa[blk(i_max,i)] = org_tmp;
21233 }
21234
21235
21236 if (aa(i, i) == value_type_()) {
21237 result = value_type_();
21238 break;
21239 }
21240
21241
21242 value_type_ factor = value_type_(1)/aa(i, i);
21243
21244 result[row(i)] *= factor;
21245 aa[blk(i, i)] *= factor;
21246
21247 value_type_ epsilon = std::numeric_limits<value_type_>::epsilon()*aa(i, i)*n;
21248
21249
21250 for (int i2 = i+1; i2<n; i2++)
21251 if (abs(aa(i2, i)) > epsilon) {
21252 result[row(i2)] -= aa(i2, i)*result[row(i)];
21253 aa[blk(i2,i)] -= aa(i2, i)*aa[blk(i,i)];
21254 }
21255 }
21256
21257
21258 for (int i = n-1; i>=0; i--) {
21259 value_type_ epsilon = std::numeric_limits<value_type_>::epsilon()*aa(i, i)*n;
21260
21261 for (int i2 = 0; i2<i; i2++)
21262 if (abs(aa(i2, i)) > epsilon)
21263
21264 result[row(i2)] -= aa(i2, i)*result[row(i)];
21265 }
21266
21267 return result;
21268 }
21269
21270
21271
21272
21273
21274 template<typename value_type_, typename traits_type_, typename rep_>
21275 LITE_INLINE
21276 typename detail::enable_if<(
21277 array_signature_traits<value_type_>::dimensions == 0),
21278 const typename array_helper<value_type_[2][2], traits_type_>::temporary_array
21279 >::type
21280 rotation_n(
21281 const array<value_type_[2], traits_type_, rep_>&,
21282 const typename array_signature_traits<value_type_>::element_type& angle)
21283 {
21284 using namespace std;
21285 typename array_helper<value_type_[2][2], traits_type_>::temporary_array result;
21286
21287 value_type_ tmp_cos = cos(angle);
21288 value_type_ tmp_sin = sin(angle);
21289
21290 result(0, 0) = tmp_cos;
21291 result(1, 1) = tmp_cos;
21292 result(0, 1) = -tmp_sin;
21293 result(1, 0) = tmp_sin;
21294
21295 return result;
21296 }
21297
21298 template<typename value_type_, typename traits_type_, typename rep_>
21299 LITE_INLINE
21300 typename detail::enable_if<(
21301 array_signature_traits<value_type_>::dimensions == 0),
21302 const typename array_helper<value_type_[2][2], traits_type_>::temporary_array
21303 >::type
21304 rotation(
21305 const array<value_type_[2], traits_type_, rep_>& dummy,
21306 const typename array_signature_traits<value_type_>::element_type& angle)
21307 {
21308 return rotation_n(dummy, angle);
21309 }
21310
21311
21312
21313
21314
21315 template<typename value_type_, typename traits_type_, typename rep_>
21316 LITE_INLINE
21317 typename detail::enable_if<(
21318 array_signature_traits<value_type_>::dimensions == 0),
21319 const typename array_helper<value_type_[3][3], traits_type_>::temporary_array
21320 >::type
21321 rotation_n(
21322 const array<value_type_[3], traits_type_, rep_>& axis,
21323 const typename array_signature_traits<value_type_>::element_type& angle)
21324 {
21325 using namespace std;
21326
21327 typedef array<value_type_[3], traits_type_, rep_> axis_type;
21328
21329 typename detail::matrix_policy<axis_type, 9> ::cached_array cached_axis = axis;
21330 typename array_helper<value_type_[3][3], traits_type_>::temporary_array result;
21331
21332 value_type_ tmp_cos = cos(angle);
21333 value_type_ tmp_sin = sin(angle);
21334 value_type_ tmp_rcos = value_type_(1) - tmp_cos;
21335
21336 result(0, 0) = tmp_cos + cached_axis[0]*cached_axis[0]*tmp_rcos;
21337 result(1, 1) = tmp_cos + cached_axis[1]*cached_axis[1]*tmp_rcos;
21338 result(2, 2) = tmp_cos + cached_axis[2]*cached_axis[2]*tmp_rcos;
21339
21340 value_type_ tmp1 = cached_axis[0]*cached_axis[1]*tmp_rcos;
21341 value_type_ tmp2 = cached_axis[2]*tmp_sin;
21342
21343 result(1, 0) = tmp1 + tmp2;
21344 result(0, 1) = tmp1 - tmp2;
21345 tmp1 = cached_axis[0]*cached_axis[2]*tmp_rcos;
21346 tmp2 = cached_axis[1]*tmp_sin;
21347 result(2, 0) = tmp1 - tmp2;
21348 result(0, 2) = tmp1 + tmp2;
21349 tmp1 = cached_axis[1]*cached_axis[2]*tmp_rcos;
21350 tmp2 = cached_axis[0]*tmp_sin;
21351 result(2, 1) = tmp1 + tmp2;
21352 result(1, 2) = tmp1 - tmp2;
21353
21354 return result;
21355 }
21356
21357 template<typename value_type_, typename traits_type_, typename rep_>
21358 LITE_INLINE
21359 typename detail::enable_if<(
21360 array_signature_traits<value_type_>::dimensions == 0),
21361 const typename array_helper<value_type_[3][3], traits_type_>::temporary_array
21362 >::type
21363 rotation(
21364 const array<value_type_[3], traits_type_, rep_>& axis,
21365 const typename array_signature_traits<value_type_>::element_type& angle)
21366 {
21367 typename array_helper<value_type_[3], traits_type_>::temporary_array normalized_axis = axis;
21368
21369 normalized_axis *= value_type_(1)/abs(normalized_axis);
21370
21371 return rotation_n(normalized_axis, angle);
21372 }
21373
21374
21375
21376
21377
21378 template<typename value_type_, int n_, typename traits_type_, typename rep_>
21379 LITE_INLINE
21380 typename detail::enable_if<(
21381 array_signature_traits<value_type_>::dimensions == 0),
21382 const typename array_helper<value_type_[n_][n_], traits_type_>::temporary_array
21383 >::type
21384 scale(const array<value_type_[n_], traits_type_, rep_>& factors)
21385 {
21386 const int n = factors.size().i0;
21387 typename array_helper<value_type_[n_][n_], traits_type_>::temporary_array
21388 result(n, n);
21389
21390 result = value_type_();
21391 result[diagonal()] = factors;
21392 return result;
21393 }
21394
21395
21396
21397
21398
21416 class array_comparator
21417 {
21418 public:
21419 LITE_INLINE array_comparator() {}
21420
21421 LITE_INLINE array_comparator(const array_comparator&) {}
21422
21423 LITE_INLINE array_comparator& operator= (array_comparator&) { return *this; }
21424
21426 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
21427 LITE_INLINE bool
21428 operator()(
21429 const array<signature_, traits_type_, l_rep_>& a,
21430 const array<signature_, traits_type_, r_rep_>& b) const
21431 {
21432 return compare(a, b) < 0;
21433 }
21434 };
21435
21436
21437
21438
21439
21440 #ifdef DOCUMENTATION_ONLY
21441
21457 template<typename value_type_, int n0_ ..., int nN_>
21458 const array<...>
21459 from(value_type_ (&a)[n0_]...[nN_]);
21460
21461 #else // DOCUMENTATION_ONLY
21462
21463 template<
21464 typename value_type_,
21465 int n0_
21466 >
21467 LITE_INLINE
21468 typename detail::enable_if<
21469 array_signature_traits<value_type_[n0_]>::is_fixed_size,
21470 const array<typename array_signature_traits<value_type_[n0_]>::signature,
21471 default_array_traits,
21472 reference_rep<typename array_signature_traits<value_type_[n0_]>::default_iterator> >
21473 >::type
21474 from(value_type_ (&a)[n0_])
21475 {
21476 typedef array<typename array_signature_traits<value_type_[n0_]>::signature,
21477 default_array_traits,
21478 reference_rep<typename array_signature_traits<value_type_[n0_]>::default_iterator>
21479 > result_type;
21480
21481 return result_type(&a[0], typename result_type::size_type());
21482 };
21483
21484 template<
21485 typename value_type_,
21486 int n0_,
21487 int n1_
21488 >
21489 LITE_INLINE
21490 typename detail::enable_if<
21491 array_signature_traits<value_type_[n0_][n1_]>::is_fixed_size,
21492 const array<typename array_signature_traits<value_type_[n0_][n1_]>::signature,
21493 default_array_traits,
21494 reference_rep<typename array_signature_traits<value_type_[n0_][n1_]>::default_iterator> >
21495 >::type
21496 from(value_type_ (&a)[n0_][n1_])
21497 {
21498 typedef array<typename array_signature_traits<value_type_[n0_][n1_]>::signature,
21499 default_array_traits,
21500 reference_rep<typename array_signature_traits<value_type_[n0_][n1_]>::default_iterator>
21501 > result_type;
21502
21503 return result_type(&a[0][0], typename result_type::size_type());
21504 };
21505
21506 template<
21507 typename value_type_,
21508 int n0_,
21509 int n1_,
21510 int n2_
21511 >
21512 LITE_INLINE
21513 typename detail::enable_if<
21514 array_signature_traits<value_type_[n0_][n1_][n2_]>::is_fixed_size,
21515 const array<typename array_signature_traits<value_type_[n0_][n1_][n2_]>::signature,
21516 default_array_traits,
21517 reference_rep<typename array_signature_traits<value_type_[n0_][n1_][n2_]>::default_iterator> >
21518 >::type
21519 from(value_type_ (&a)[n0_][n1_][n2_])
21520 {
21521 typedef array<typename array_signature_traits<value_type_[n0_][n1_][n2_]>::signature,
21522 default_array_traits,
21523 reference_rep<typename array_signature_traits<value_type_[n0_][n1_][n2_]>::default_iterator>
21524 > result_type;
21525
21526 return result_type(&a[0][0][0], typename result_type::size_type());
21527 };
21528
21529
21530 #endif // DOCUMENTATION_ONLY
21531
21532
21533
21534
21535
21536 #ifdef DOCUMENTATION_ONLY
21537
21556 template<typename iterator_type_>
21557 const array<...>
21558 from(iterator_type_ it, int n0 ..., int nN);
21559
21560 #else // DOCUMENTATION_ONLY
21561
21562 template<typename iterator_type_>
21563 LITE_INLINE
21564 const array<
21565 typename std::iterator_traits<iterator_type_>::value_type[1],
21566 default_array_traits,
21567 reference_rep<pack<iterator_type_, constant<int, 1> > > >
21568 from(iterator_type_ it, int n0)
21569 {
21570 typedef array<
21571 typename std::iterator_traits<iterator_type_>::value_type[1],
21572 default_array_traits,
21573 reference_rep<pack<iterator_type_, constant<int, 1> > >
21574 > result_type;
21575
21576 typedef typename result_type::iterator iterator_type;
21577
21578 return result_type(
21579 iterator_type(it, 1),
21580 typename result_type::size_type(n0));
21581 }
21582
21583 template<typename iterator_type_>
21584 LITE_INLINE
21585 const array<
21586 typename std::iterator_traits<iterator_type_>::value_type[1][1],
21587 default_array_traits,
21588 reference_rep<pack<iterator_type_, int, constant<int, 1> > > >
21589 from(iterator_type_ it, int n0, int n1)
21590 {
21591 typedef array<
21592 typename std::iterator_traits<iterator_type_>::value_type[1][1],
21593 default_array_traits,
21594 reference_rep<pack<iterator_type_, int, constant<int, 1> > >
21595 > result_type;
21596
21597 typedef typename result_type::iterator iterator_type;
21598
21599 return result_type(
21600 iterator_type(it, n1, 1),
21601 typename result_type::size_type(n0,n1));
21602 }
21603
21604 template<typename iterator_type_>
21605 LITE_INLINE
21606 const array<
21607 typename std::iterator_traits<iterator_type_>::value_type[1][1][1],
21608 default_array_traits,
21609 reference_rep<pack<iterator_type_, int, int, constant<int, 1> > > >
21610 from(iterator_type_ it, int n0, int n1, int n2)
21611 {
21612 typedef array<
21613 typename std::iterator_traits<iterator_type_>::value_type[1][1][1],
21614 default_array_traits,
21615 reference_rep<pack<iterator_type_, int, int, constant<int, 1> > >
21616 > result_type;
21617
21618 typedef typename result_type::iterator iterator_type;
21619
21620 return result_type(
21621 iterator_type(it, n1*n2, n2, 1),
21622 typename result_type::size_type(n0,n1,n2));
21623 }
21624
21625
21626 #endif // DOCUMENTATION_ONLY
21627
21628
21629
21630
21631
21632 #ifdef DOCUMENTATION_ONLY
21633
21652 template<typename iterator_type_, typename type0_ ..., typename typeN_>
21653 const array<...>
21654 from(iterator_type_ it, const pack<type0_ ..., typeN_>& size);
21655
21656 #else // DOCUMENTATION_ONLY
21657
21658
21659 template<
21660 typename iterator_type_,
21661 typename type0_
21662 >
21663 LITE_INLINE
21664 const array<
21665 typename detail::size_to_signature<
21666 pack<type0_>,
21667 typename std::iterator_traits<iterator_type_>::value_type
21668 >::type,
21669 default_array_traits,
21670 reference_rep<
21671 typename array_signature_traits<
21672 typename detail::size_to_signature<
21673 pack<type0_>,
21674 typename std::iterator_traits<iterator_type_>::value_type
21675 >::type,
21676 iterator_type_
21677 >::default_iterator>
21678 >
21679 from(
21680 iterator_type_ it,
21681 const pack<type0_>& size)
21682 {
21683 typedef array<
21684 typename detail::size_to_signature<
21685 pack<type0_>,
21686 typename std::iterator_traits<iterator_type_>::value_type
21687 >::type,
21688 default_array_traits,
21689 reference_rep<
21690 typename array_signature_traits<
21691 typename detail::size_to_signature<
21692 pack<type0_>,
21693 typename std::iterator_traits<iterator_type_>::value_type
21694 >::type,
21695 iterator_type_
21696 >::default_iterator>
21697 > result_type;
21698
21699 typedef typename result_type::iterator iterator_type;
21700
21701 return result_type(
21702 iterator_type(it, 1),
21703 size);
21704 }
21705
21706 template<
21707 typename iterator_type_,
21708 typename type0_,
21709 typename type1_
21710 >
21711 LITE_INLINE
21712 const array<
21713 typename detail::size_to_signature<
21714 pack<type0_,type1_>,
21715 typename std::iterator_traits<iterator_type_>::value_type
21716 >::type,
21717 default_array_traits,
21718 reference_rep<
21719 typename array_signature_traits<
21720 typename detail::size_to_signature<
21721 pack<type0_,type1_>,
21722 typename std::iterator_traits<iterator_type_>::value_type
21723 >::type,
21724 iterator_type_
21725 >::default_iterator>
21726 >
21727 from(
21728 iterator_type_ it,
21729 const pack<type0_, type1_>& size)
21730 {
21731 typedef array<
21732 typename detail::size_to_signature<
21733 pack<type0_,type1_>,
21734 typename std::iterator_traits<iterator_type_>::value_type
21735 >::type,
21736 default_array_traits,
21737 reference_rep<
21738 typename array_signature_traits<
21739 typename detail::size_to_signature<
21740 pack<type0_,type1_>,
21741 typename std::iterator_traits<iterator_type_>::value_type
21742 >::type,
21743 iterator_type_
21744 >::default_iterator>
21745 > result_type;
21746
21747 typedef typename result_type::iterator iterator_type;
21748
21749 return result_type(
21750 iterator_type(it, size.i1, 1),
21751 size);
21752 }
21753
21754 template<
21755 typename iterator_type_,
21756 typename type0_,
21757 typename type1_,
21758 typename type2_
21759 >
21760 LITE_INLINE
21761 const array<
21762 typename detail::size_to_signature<
21763 pack<type0_,type1_,type2_>,
21764 typename std::iterator_traits<iterator_type_>::value_type
21765 >::type,
21766 default_array_traits,
21767 reference_rep<
21768 typename array_signature_traits<
21769 typename detail::size_to_signature<
21770 pack<type0_,type1_,type2_>,
21771 typename std::iterator_traits<iterator_type_>::value_type
21772 >::type,
21773 iterator_type_
21774 >::default_iterator>
21775 >
21776 from(
21777 iterator_type_ it,
21778 const pack<type0_, type1_, type2_>& size)
21779 {
21780 typedef array<
21781 typename detail::size_to_signature<
21782 pack<type0_,type1_,type2_>,
21783 typename std::iterator_traits<iterator_type_>::value_type
21784 >::type,
21785 default_array_traits,
21786 reference_rep<
21787 typename array_signature_traits<
21788 typename detail::size_to_signature<
21789 pack<type0_,type1_,type2_>,
21790 typename std::iterator_traits<iterator_type_>::value_type
21791 >::type,
21792 iterator_type_
21793 >::default_iterator>
21794 > result_type;
21795
21796 typedef typename result_type::iterator iterator_type;
21797
21798 return result_type(
21799 iterator_type(it, size.i1*size.i2, size.i2, 1),
21800 size);
21801 }
21802
21803
21804 #endif // !DOCUMENTATION_ONLY
21805
21806
21807
21808
21809
21810 template<typename signature_, typename traits_type_, typename rep_>
21811 LITE_INLINE
21812 array<signature_, traits_type_, rep_>&
21813 from(array<signature_, traits_type_, rep_>& a)
21814 {
21815 return a;
21816 }
21817
21818 template<typename signature_, typename traits_type_, typename rep_>
21819 LITE_INLINE
21820 const array<signature_, traits_type_, rep_>&
21821 from(const array<signature_, traits_type_, rep_>& a)
21822 {
21823 return a;
21824 }
21825
21826
21827
21828
21829
21830 #ifdef DOCUMENTATION_ONLY
21831
21855 template<
21856 typename dst_array_type_,
21857 typename src_signature_,
21858 typename src_traits_type_,
21859 typename src_rep_>
21860 const array<...>
21861 array_cast(const array<src_signature_, src_traits_type_, src_rep_>& ar);
21862
21863 #else // DOCUMENTATION_ONLY
21864
21865 template<
21866 typename dst_array_type_,
21867 typename src_signature_,
21868 typename src_traits_type_,
21869 typename src_rep_>
21870 LITE_INLINE
21871 typename detail::enable_if<
21872 (array_signature_traits<src_signature_>::dimensions == dst_array_type_::dimensions),
21873 const array<
21874 typename dst_array_type_::signature,
21875 typename dst_array_type_::traits_type,
21876 reference_rep<typename array<src_signature_, src_traits_type_, src_rep_>::const_iterator> >
21877 >::type
21878 array_cast(const array<src_signature_, src_traits_type_, src_rep_>& a)
21879 {
21880 typedef array<
21881 typename dst_array_type_::signature,
21882 typename dst_array_type_::traits_type,
21883 reference_rep<typename array<src_signature_, src_traits_type_, src_rep_>::const_iterator> >
21884 result_type;
21885
21886 typename result_type::size_type new_size(a.size());
21887
21888 LITE_ARRAY_SIZE_CHECK(a.size(), new_size, "array_cast<A>(A): source/target sizes do not match");
21889
21890 return result_type(a.begin(), new_size);
21891 }
21892
21893 template<
21894 typename dst_array_type_,
21895 typename src_signature_,
21896 typename src_traits_type_,
21897 typename src_rep_>
21898 LITE_INLINE
21899 typename detail::enable_if<
21900 (array_signature_traits<src_signature_>::dimensions == dst_array_type_::dimensions),
21901 const array<
21902 typename dst_array_type_::signature,
21903 typename dst_array_type_::traits_type,
21904 reference_rep<typename array<src_signature_, src_traits_type_, src_rep_>::iterator> >
21905 >::type
21906 array_cast(array<src_signature_, src_traits_type_, src_rep_>& a)
21907 {
21908 typedef array<
21909 typename dst_array_type_::signature,
21910 typename dst_array_type_::traits_type,
21911 reference_rep<typename array<src_signature_, src_traits_type_, src_rep_>::iterator> >
21912 result_type;
21913
21914 typename result_type::size_type new_size(a.size());
21915
21916 LITE_ARRAY_SIZE_CHECK(a.size(), new_size, "array_cast<A>(A): source/target sizes do not match");
21917
21918 return result_type(a.begin(), new_size);
21919 }
21920
21921 #endif // !DOCUMENTATION_ONLY
21922
21923
21924
21925
21926
21927 template<
21928 typename char_type_ ,
21929 typename char_traits_type_,
21930 typename value_type_,
21931 typename traits_type_,
21932 typename rep_>
21933 void print(
21934 std::basic_ostream<char_type_, char_traits_type_>& os,
21935 const array<value_type_, traits_type_, rep_>& ar,
21936 int level
21937 )
21938 {
21939 std::streamsize width = os.width();
21940 bool punct = (os.flags() & std::ios_base::boolalpha) != 0;
21941
21942 os.width(0);
21943
21944 if (punct)
21945 os << '[';
21946
21947 os.width(width);
21948 os << ar();
21949
21950 if (punct)
21951 os << ']';
21952 }
21953
21954 template<
21955 typename char_type_ ,
21956 typename char_traits_type_,
21957 typename value_type_,
21958 int n0_,
21959 typename traits_type_,
21960 typename rep_>
21961 void print(
21962 std::basic_ostream<char_type_, char_traits_type_>& os,
21963 const array<value_type_[n0_], traits_type_, rep_>& ar,
21964 int
21965 )
21966 {
21967 std::streamsize width = os.width();
21968 bool punct = (os.flags() & std::ios_base::boolalpha) != 0;
21969 const int n =ar.size().i0;
21970
21971 os.width(0);
21972
21973 if (punct)
21974 os << '[';
21975
21976 for (int i=0; i<n; i++) {
21977 if (i != 0)
21978 os << ' ';
21979 os.width(width);
21980 os << ar[i];
21981 }
21982
21983 if (punct)
21984 os << ']';
21985 }
21986
21987 template<
21988 typename char_type_ ,
21989 typename char_traits_type_,
21990 typename tail_type_,
21991 int n0_,
21992 int n1_,
21993 typename traits_type_,
21994 typename rep_>
21995 void print(
21996 std::basic_ostream<char_type_, char_traits_type_>& os,
21997 const array<tail_type_[n0_][n1_], traits_type_, rep_>& ar,
21998 int level =0
21999 )
22000 {
22001 std::streamsize width = os.width();
22002 bool punct = (os.flags() & std::ios_base::boolalpha) != 0;
22003 const int n =ar.size().i0;
22004
22005 os.width(0);
22006
22007 if (punct) {
22008 os << '[' << '\n';
22009 for (int j=0; j<level; j++) { os.width(width); os << ' '; }
22010 }
22011 for (int i=0; i<n; i++) {
22012 os.width(width);
22013 os << ' ';
22014 os.width(width);
22015 print(os, ar[row(i)], level+1);
22016 if (i < n-1) {
22017 os << "\n";
22018 for (int j=0; j<level; j++) { os.width(width); os << ' '; }
22019 }
22020 }
22021 if (punct) {
22022 os << '\n';
22023 for (int j=0; j<level; j++) { os.width(width); os << ' '; }
22024 os << ']';
22025 }
22026 }
22027
22056 template<
22057 typename char_type_ ,
22058 typename char_traits_type_,
22059 typename signature_,
22060 typename traits_type_,
22061 typename rep_>
22062 std::basic_ostream<char_type_, char_traits_type_>&
22063 operator<<(
22064 std::basic_ostream<char_type_, char_traits_type_>& os,
22065 const array<signature_, traits_type_, rep_>& ar)
22066 {
22067 print(os, ar, 0);
22068 return os;
22069 }
22070
22071
22072
22073
22074
22075 template<
22076 typename char_type_ ,
22077 typename char_traits_type_,
22078 typename value_type_,
22079 typename traits_type_,
22080 typename rep_>
22081 void scan(
22082 std::basic_istream<char_type_, char_traits_type_>& is,
22083 const array<value_type_, traits_type_, rep_>& ar,
22084 bool fancy
22085 )
22086 {
22087 char_type_ ch;
22088
22089 if (fancy && !(is >> ch && is.narrow(ch, '\0') == '[')) {
22090 is.setstate(std::ios_base::failbit);
22091 return;
22092 }
22093
22094 is >> ar();
22095
22096 ch = char_type_();
22097
22098 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
22099 is.setstate(std::ios_base::failbit);
22100 return;
22101 }
22102 }
22103
22104 template<
22105 typename char_type_ ,
22106 typename char_traits_type_,
22107 typename value_type_,
22108 typename traits_type_,
22109 typename rep_>
22110 void scan(
22111 std::basic_istream<char_type_, char_traits_type_>& is,
22112 array<value_type_, traits_type_, rep_>& ar,
22113 bool fancy
22114 )
22115 {
22116 char_type_ ch;
22117
22118 if (fancy && !(is >> ch && is.narrow(ch, '\0') == '[')) {
22119 is.setstate(std::ios_base::failbit);
22120 return;
22121 }
22122
22123 is >> ar();
22124
22125 ch = char_type_();
22126
22127 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
22128 is.setstate(std::ios_base::failbit);
22129 return;
22130 }
22131 }
22132
22133
22134
22135 template<
22136 typename char_type_ ,
22137 typename char_traits_type_,
22138 typename value_type_,
22139 int n0_,
22140 typename traits_type_,
22141 typename rep_>
22142 void scan(
22143 std::basic_istream<char_type_, char_traits_type_>& is,
22144 const array<value_type_[n0_], traits_type_, rep_>& ar,
22145 bool fancy
22146 )
22147 {
22148 const int n =ar.size().i0;
22149 char_type_ ch;
22150
22151 if (fancy && !(is >> ch && is.narrow(ch, '\0') == '[')) {
22152 is.setstate(std::ios_base::failbit);
22153 return;
22154 }
22155
22156 for (int i=0; i<n; i++)
22157 is >> ar[i];
22158
22159 ch = char_type_();
22160
22161 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
22162 is.setstate(std::ios_base::failbit);
22163 return;
22164 }
22165 }
22166
22167 template<
22168 typename char_type_ ,
22169 typename char_traits_type_,
22170 typename value_type_,
22171 int n0_,
22172 typename traits_type_,
22173 typename rep_>
22174 void scan(
22175 std::basic_istream<char_type_, char_traits_type_>& is,
22176 array<value_type_[n0_], traits_type_, rep_>& ar,
22177 bool fancy
22178 )
22179 {
22180 const int n =ar.size().i0;
22181 char_type_ ch;
22182
22183 if (fancy && !(is >> ch && is.narrow(ch, '\0') == '[')) {
22184 is.setstate(std::ios_base::failbit);
22185 return;
22186 }
22187
22188 for (int i=0; i<n; i++)
22189 is >> ar[i];
22190
22191 ch = char_type_();
22192
22193 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
22194 is.setstate(std::ios_base::failbit);
22195 return;
22196 }
22197 }
22198
22199
22200
22201 template<
22202 typename char_type_ ,
22203 typename char_traits_type_,
22204 typename tail_type_,
22205 int n0_,
22206 int n1_,
22207 typename traits_type_,
22208 typename rep_>
22209 void scan(
22210 std::basic_istream<char_type_, char_traits_type_>& is,
22211 const array<tail_type_[n0_][n1_], traits_type_, rep_>& ar,
22212 bool fancy
22213 )
22214 {
22215 const int n =ar.size().i0;
22216 char_type_ ch;
22217
22218 if (fancy && !(is >> ch && is.narrow(ch, '\0') == '[')) {
22219 is.setstate(std::ios_base::failbit);
22220 return;
22221 }
22222
22223 for (int i=0; i<n; i++)
22224 scan(is, ar[row(i)], fancy);
22225
22226 ch = char_type_();
22227
22228 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
22229 is.setstate(std::ios_base::failbit);
22230 return;
22231 }
22232 }
22233
22234
22235 template<
22236 typename char_type_ ,
22237 typename char_traits_type_,
22238 typename tail_type_,
22239 int n0_,
22240 int n1_,
22241 typename traits_type_,
22242 typename rep_>
22243 void scan(
22244 std::basic_istream<char_type_, char_traits_type_>& is,
22245 array<tail_type_[n0_][n1_], traits_type_, rep_>& ar,
22246 bool fancy
22247 )
22248 {
22249 const int n =ar.size().i0;
22250 char_type_ ch;
22251
22252 if (fancy && !(is >> ch && is.narrow(ch, '\0') == '[')) {
22253 is.setstate(std::ios_base::failbit);
22254 return;
22255 }
22256
22257 for (int i=0; i<n; i++)
22258 scan(is, ar[row(i)], fancy);
22259
22260 ch = char_type_();
22261
22262 if (fancy && !(is >> ch && is.narrow(ch, '\0') == ']')) {
22263 is.setstate(std::ios_base::failbit);
22264 return;
22265 }
22266 }
22267
22268
22269
22299 template<
22300 typename char_type_ ,
22301 typename char_traits_type_,
22302 typename signature_,
22303 typename traits_type_,
22304 typename rep_>
22305 std::basic_istream<char_type_, char_traits_type_>&
22306 operator>>(
22307 std::basic_istream<char_type_, char_traits_type_>& is,
22308 const array<signature_, traits_type_, rep_>& ar)
22309 {
22310 char_type_ ch;
22311
22312 if (!(is >> ch))
22313 return is;
22314
22315 bool fancy = is.narrow(ch, '\0') == '[';
22316
22317 is.putback(ch);
22318 scan(is, ar, fancy);
22319 return is;
22320 }
22321
22354 template<
22355 typename char_type_ ,
22356 typename char_traits_type_,
22357 typename signature_,
22358 typename traits_type_,
22359 typename rep_>
22360 std::basic_istream<char_type_, char_traits_type_>&
22361 operator>>(
22362 std::basic_istream<char_type_, char_traits_type_>& is,
22363 array<signature_, traits_type_, rep_>& ar)
22364 {
22365 char_type_ ch;
22366
22367 if (!(is >> ch))
22368 return is;
22369
22370 bool fancy = is.narrow(ch, '\0') == '[';
22371
22372 is.putback(ch);
22373 scan(is, ar, fancy);
22374 return is;
22375 }
22376
22377 }
22378
22379
22380
22381
22382 namespace std {
22383
22384 template<typename signature_, typename traits_type_, typename rep_>
22385 LITE_INLINE void
22386 swap(
22387 const lite::array<signature_, traits_type_, rep_>& a,
22388 const lite::array<signature_, traits_type_, rep_>& b)
22389 {
22390 a.swap(b);
22391 }
22392
22393 template<typename signature_, typename traits_type_, typename rep_>
22394 LITE_INLINE void
22395 swap(
22396 lite::array<signature_, traits_type_, rep_>& a,
22397 lite::array<signature_, traits_type_, rep_>& b)
22398 {
22399 a.swap(b);
22400 }
22401
22402 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
22403 LITE_INLINE void
22404 swap(
22405 const lite::array<signature_, traits_type_, l_rep_>& a,
22406 const lite::array<signature_, traits_type_, r_rep_>& b)
22407 {
22408 a.swap(b);
22409 }
22410
22411 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
22412 LITE_INLINE void
22413 swap(
22414 const lite::array<signature_, traits_type_, l_rep_>& a,
22415 lite::array<signature_, traits_type_, r_rep_>& b)
22416 {
22417 a.swap(b);
22418 }
22419
22420 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
22421 LITE_INLINE void
22422 swap(
22423 lite::array<signature_, traits_type_, l_rep_>& a,
22424 const lite::array<signature_, traits_type_, r_rep_>& b)
22425 {
22426 a.swap(b);
22427 }
22428
22429 template<typename signature_, typename traits_type_, typename l_rep_, typename r_rep_>
22430 LITE_INLINE void
22431 swap(
22432 lite::array<signature_, traits_type_, l_rep_>& a,
22433 lite::array<signature_, traits_type_, r_rep_>& b)
22434 {
22435 a.swap(b);
22436 }
22437
22438 }
22439
22440 #ifdef _MSC_VER
22441 #pragma warning(pop)
22442 #endif // _MSC_VER
22443
22444 #endif // ARRAY_HPP
22445
22446
22447
22448