is_resizeable.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <type_traits>
  17. #include <boost/type_traits/integral_constant.hpp>
  18. #include <boost/type_traits/remove_reference.hpp>
  19. #include <boost/fusion/include/front.hpp>
  20. #include <boost/fusion/include/is_sequence.hpp>
  21. #include <boost/mpl/find_if.hpp>
  22. #include <boost/mpl/end.hpp>
  23. #include <boost/mpl/placeholders.hpp>
  24. #include <boost/mpl/if.hpp>
  25. #include <boost/type_traits/is_same.hpp>
  26. namespace boost {
  27. namespace numeric {
  28. namespace odeint {
  29. /*
  30. * by default any type is not resizable
  31. */
  32. template< typename Container , typename Enabler = void >
  33. struct is_resizeable_sfinae : std::false_type {};
  34. template< typename Container >
  35. struct is_resizeable : is_resizeable_sfinae< Container > {};
  36. /*
  37. * specialization for std::vector
  38. */
  39. template< class V, class A >
  40. struct is_resizeable< std::vector< V , A > > : std::true_type {};
  41. /*
  42. * sfinae specialization for fusion sequences
  43. */
  44. template< typename FusionSequence >
  45. struct is_resizeable_sfinae<
  46. FusionSequence ,
  47. typename boost::enable_if< typename boost::fusion::traits::is_sequence< FusionSequence >::type >::type >
  48. {
  49. typedef typename boost::mpl::find_if< FusionSequence , is_resizeable< boost::mpl::_1 > >::type iter;
  50. typedef typename boost::mpl::end< FusionSequence >::type last;
  51. typedef typename boost::mpl::if_< boost::is_same< iter , last > , std::false_type , std::true_type >::type type;
  52. const static bool value = type::value;
  53. };
  54. } // namespace odeint
  55. } // namespace numeric
  56. } // namespace boost
  57. #endif // BOOST_NUMERIC_ODEINT_UTIL_IS_RESIZEABLE_HPP_INCLUDED