~ubuntu-branches/ubuntu/vivid/gnuplot-iostream/vivid

« back to all changes in this revision

Viewing changes to gnuplot-iostream.h

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2013-06-05 08:32:47 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130605083247-uqzgr7cbvs6yudtk
Tags: 0~20130604.gitdd47c7a-1
* [642dade] Imported Upstream version 0~20130604.gitdd47c7a
* [b34ffd5] Enable all tests again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
 
147
147
/// {{{1 Basic traits helpers
148
148
 
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 {
152
 
//    typedef char one;
153
 
//    typedef long two;
154
 
//
155
 
//    template <typename C> static one test(typename C::value_type *, typename C::const_iterator *);
156
 
//    template <typename C> static two test(...);
157
 
//
158
 
//public:
159
 
//    static const bool value = sizeof(test<T>(NULL, NULL)) == sizeof(char);
160
 
//      typedef boost::mpl::bool_<value> type;
161
 
//};
 
149
// This can be specialized as needed, in order to not use the STL interfaces for specific
 
150
// classes.
 
151
template <typename T>
 
152
struct dont_treat_as_stl_container {
 
153
        typedef boost::mpl::bool_<false> type;
 
154
};
162
155
 
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> >
171
165
                > type;
172
166
        static const bool value = type::value;
173
167
};
174
168
 
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 { };
179
 
 
180
 
    template<typename C, C> struct ChT;
181
 
 
182
 
    template<typename C> static char (&f(ChT<int Fallback::*, &C::n_rows>*))[1];
183
 
    template<typename C> static char (&f(...))[2];
184
 
 
185
 
    static bool const value = sizeof(f<Derived>(0)) == 2;
186
 
        typedef boost::mpl::bool_<value> type;
187
 
};
188
 
 
189
 
template<typename T> struct has_attrib_n_cols {
190
 
    struct Fallback { int n_cols; };
191
 
    struct Derived : T, Fallback { };
192
 
 
193
 
    template<typename C, C> struct ChT;
194
 
 
195
 
    template<typename C> static char (&f(ChT<int Fallback::*, &C::n_cols>*))[1];
196
 
    template<typename C> static char (&f(...))[2];
197
 
 
198
 
    static bool const value = sizeof(f<Derived>(0)) == 2;
199
 
        typedef boost::mpl::bool_<value> type;
200
 
};
201
 
 
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);
205
 
 
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
214
 
                > type;
215
 
};
216
 
 
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;
227
179
};
228
180
 
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 {
232
 
//    typedef char one;
233
 
//    typedef long two;
234
 
//
235
 
//    template <typename C> static one test(typename C::head_type *, typename C::tail_type *);
236
 
//    template <typename C> static two test(...);
237
 
//
238
 
//public:
239
 
//    static const bool value = sizeof(test<T>(NULL, NULL)) == sizeof(char);
240
 
//      typedef boost::mpl::bool_<value> type;
241
 
//};
242
 
 
243
181
BOOST_MPL_HAS_XXX_TRAIT_DEF(head_type)
244
182
BOOST_MPL_HAS_XXX_TRAIT_DEF(tail_type)
245
183
 
830
768
};
831
769
 
832
770
template <typename T>
833
 
class ArrayTraits<T, typename boost::enable_if<
834
 
        boost::mpl::and_<
835
 
                is_like_stl_container<T>,
836
 
                boost::mpl::not_<is_armadillo_container<T> >
837
 
        >
838
 
>::type> : public ArrayTraitsDefaults<typename T::value_type> {
 
771
class ArrayTraits<T,
 
772
          typename boost::enable_if<is_like_stl_container<T> >::type
 
773
> : public ArrayTraitsDefaults<typename T::value_type> {
839
774
public:
840
775
        typedef IteratorRange<typename T::const_iterator, typename T::value_type> range_type;
841
776
 
1763
1698
#define GNUPLOT_ARMADILLO_SUPPORT_LOADED
1764
1699
namespace gnuplotio {
1765
1700
 
 
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; };
 
1706
 
1766
1707
/// {{{3 Cube
1767
1708
 
1768
1709
template <typename T>