1 | /* |
2 | [auto_generated] |
3 | boost/numeric/odeint/util/is_resizeable.hpp |
4 | |
5 | [begin_description] |
6 | Metafunction to determine if a state type can resized. For usage in the steppers. |
7 | [end_description] |
8 | |
9 | Copyright 2011-2012 Karsten Ahnert |
10 | Copyright 2011 Mario Mulansky |
11 | |
12 | Distributed under the Boost Software License, Version 1.0. |
13 | (See accompanying file LICENSE_1_0.txt or |
14 | copy at http://www.boost.org/LICENSE_1_0.txt) |
15 | */ |
16 | |
17 | |
18 | #ifndef BOOST_NUMERIC_ODEINT_UTIL_IS_RESIZEABLE_HPP_INCLUDED |
19 | #define BOOST_NUMERIC_ODEINT_UTIL_IS_RESIZEABLE_HPP_INCLUDED |
20 | |
21 | |
22 | #include <vector> |
23 | |
24 | #include <boost/type_traits/integral_constant.hpp> |
25 | #include <boost/type_traits/remove_reference.hpp> |
26 | #include <boost/fusion/include/front.hpp> |
27 | #include <boost/fusion/include/is_sequence.hpp> |
28 | |
29 | #include <boost/mpl/find_if.hpp> |
30 | #include <boost/mpl/end.hpp> |
31 | #include <boost/mpl/placeholders.hpp> |
32 | #include <boost/mpl/if.hpp> |
33 | #include <boost/type_traits/is_same.hpp> |
34 | |
35 | namespace boost { |
36 | namespace numeric { |
37 | namespace odeint { |
38 | |
39 | /* |
40 | * by default any type is not resizable |
41 | */ |
42 | template< typename Container , typename Enabler = void > |
43 | struct is_resizeable_sfinae : boost::false_type {}; |
44 | |
45 | template< typename Container > |
46 | struct is_resizeable : is_resizeable_sfinae< Container > {}; |
47 | |
48 | |
49 | |
50 | /* |
51 | * specialization for std::vector |
52 | */ |
53 | template< class V, class A > |
54 | struct is_resizeable< std::vector< V , A > > : boost::true_type {}; |
55 | |
56 | |
57 | /* |
58 | * sfinae specialization for fusion sequences |
59 | */ |
60 | template< typename FusionSequence > |
61 | struct is_resizeable_sfinae< |
62 | FusionSequence , |
63 | typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSequence >::type >::type > |
64 | { |
65 | typedef typename boost::mpl::find_if< FusionSequence , is_resizeable< boost::mpl::_1 > >::type iter; |
66 | typedef typename boost::mpl::end< FusionSequence >::type last; |
67 | |
68 | typedef typename boost::mpl::if_< boost::is_same< iter , last > , boost::false_type , boost::true_type >::type type; |
69 | const static bool value = type::value; |
70 | }; |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | |
77 | } // namespace odeint |
78 | } // namespace numeric |
79 | } // namespace boost |
80 | |
81 | |
82 | |
83 | #endif // BOOST_NUMERIC_ODEINT_UTIL_IS_RESIZEABLE_HPP_INCLUDED |
84 | |