resizer.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/util/resizer.hpp
  4. [begin_description]
  5. Implementation of the resizers.
  6. [end_description]
  7. Copyright 2011-2012 Mario Mulansky
  8. Copyright 2011 Karsten Ahnert
  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_RESIZER_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_UTIL_RESIZER_HPP_INCLUDED
  15. #include <boost/numeric/odeint/util/is_resizeable.hpp>
  16. #include <boost/numeric/odeint/util/same_size.hpp>
  17. #include <boost/numeric/odeint/util/resize.hpp>
  18. #include <type_traits>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. template< class ResizeWrappedState , class State >
  23. bool adjust_size_by_resizeability( ResizeWrappedState &x , const State &y , std::true_type )
  24. {
  25. if ( !same_size( x.m_v , y ) )
  26. {
  27. resize( x.m_v , y );
  28. return true;
  29. }
  30. else
  31. return false;
  32. }
  33. template< class ResizeWrappedState , class State >
  34. bool adjust_size_by_resizeability( ResizeWrappedState & /* x */ , const State & /* y */ , std::false_type )
  35. {
  36. return false;
  37. }
  38. struct always_resizer
  39. {
  40. template< class State , class ResizeFunction >
  41. bool adjust_size( const State &x , ResizeFunction f )
  42. {
  43. return f( x );
  44. }
  45. };
  46. struct initially_resizer
  47. {
  48. bool m_initialized;
  49. initially_resizer() : m_initialized( false )
  50. { }
  51. template< class State , class ResizeFunction >
  52. bool adjust_size( const State &x , ResizeFunction f )
  53. {
  54. if( !m_initialized )
  55. {
  56. m_initialized = true;
  57. return f( x );
  58. } else
  59. return false;
  60. }
  61. };
  62. struct never_resizer
  63. {
  64. template< class State , class ResizeFunction >
  65. bool adjust_size( const State &/*x*/ , ResizeFunction /*f*/ )
  66. {
  67. return false;
  68. }
  69. };
  70. }
  71. }
  72. }
  73. #endif // BOOST_NUMERIC_ODEINT_UTIL_RESIZER_HPP_INCLUDED