147
147
/// {{{1 Basic traits helpers
149
// Old version, to be used if BOOST_MPL_HAS_XXX_TRAIT_DEF doesn't work well.
150
//template <typename T>
151
//class is_like_stl_container {
155
// template <typename C> static one test(typename C::value_type *, typename C::const_iterator *);
156
// template <typename C> static two test(...);
159
// static const bool value = sizeof(test<T>(NULL, NULL)) == sizeof(char);
160
// typedef boost::mpl::bool_<value> type;
149
// This can be specialized as needed, in order to not use the STL interfaces for specific
151
template <typename T>
152
struct dont_treat_as_stl_container {
153
typedef boost::mpl::bool_<false> type;
163
156
BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
164
157
BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator)
167
160
struct is_like_stl_container {
168
161
typedef boost::mpl::and_<
169
162
typename has_value_type<T>::type,
170
typename has_const_iterator<T>::type
163
typename has_const_iterator<T>::type,
164
boost::mpl::not_<dont_treat_as_stl_container<T> >
172
166
static const bool value = type::value;
175
// http://stackoverflow.com/a/1007175/1048959
176
template<typename T> struct has_attrib_n_rows {
177
struct Fallback { int n_rows; };
178
struct Derived : T, Fallback { };
180
template<typename C, C> struct ChT;
182
template<typename C> static char (&f(ChT<int Fallback::*, &C::n_rows>*))[1];
183
template<typename C> static char (&f(...))[2];
185
static bool const value = sizeof(f<Derived>(0)) == 2;
186
typedef boost::mpl::bool_<value> type;
189
template<typename T> struct has_attrib_n_cols {
190
struct Fallback { int n_cols; };
191
struct Derived : T, Fallback { };
193
template<typename C, C> struct ChT;
195
template<typename C> static char (&f(ChT<int Fallback::*, &C::n_cols>*))[1];
196
template<typename C> static char (&f(...))[2];
198
static bool const value = sizeof(f<Derived>(0)) == 2;
199
typedef boost::mpl::bool_<value> type;
202
BOOST_MPL_HAS_XXX_TRAIT_DEF(elem_type);
203
BOOST_MPL_HAS_XXX_TRAIT_DEF(pod_type);
204
BOOST_MPL_HAS_XXX_TRAIT_DEF(col_iterator);
206
template <typename T>
207
struct is_armadillo_container {
208
typedef boost::mpl::and_<
209
typename has_attrib_n_rows<T>::type,
210
typename has_attrib_n_cols<T>::type,
211
typename has_elem_type<T>::type,
212
typename has_pod_type<T>::type,
213
typename has_col_iterator<T>::type
217
169
template <typename T>
218
170
struct is_boost_tuple_nulltype {
219
171
static const bool value = false;
226
178
typedef boost::mpl::bool_<value> type;
229
// Old version, to be used if BOOST_MPL_HAS_XXX_TRAIT_DEF doesn't work well.
230
//template <typename T>
231
//class is_boost_tuple {
235
// template <typename C> static one test(typename C::head_type *, typename C::tail_type *);
236
// template <typename C> static two test(...);
239
// static const bool value = sizeof(test<T>(NULL, NULL)) == sizeof(char);
240
// typedef boost::mpl::bool_<value> type;
243
181
BOOST_MPL_HAS_XXX_TRAIT_DEF(head_type)
244
182
BOOST_MPL_HAS_XXX_TRAIT_DEF(tail_type)
832
770
template <typename T>
833
class ArrayTraits<T, typename boost::enable_if<
835
is_like_stl_container<T>,
836
boost::mpl::not_<is_armadillo_container<T> >
838
>::type> : public ArrayTraitsDefaults<typename T::value_type> {
772
typename boost::enable_if<is_like_stl_container<T> >::type
773
> : public ArrayTraitsDefaults<typename T::value_type> {
840
775
typedef IteratorRange<typename T::const_iterator, typename T::value_type> range_type;
1763
1698
#define GNUPLOT_ARMADILLO_SUPPORT_LOADED
1764
1699
namespace gnuplotio {
1701
template <typename T> struct dont_treat_as_stl_container<arma::Row <T> > { typedef boost::mpl::bool_<true> type; };
1702
template <typename T> struct dont_treat_as_stl_container<arma::Col <T> > { typedef boost::mpl::bool_<true> type; };
1703
template <typename T> struct dont_treat_as_stl_container<arma::Mat <T> > { typedef boost::mpl::bool_<true> type; };
1704
template <typename T> struct dont_treat_as_stl_container<arma::Cube <T> > { typedef boost::mpl::bool_<true> type; };
1705
template <typename T> struct dont_treat_as_stl_container<arma::field<T> > { typedef boost::mpl::bool_<true> type; };
1768
1709
template <typename T>