is_resizeable.hpp 2.1 KB

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