same_instance.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/util/same_instance.hpp
  4. [begin_description]
  5. Basic check if two variables are the same instance
  6. [end_description]
  7. Copyright 2012 Karsten Ahnert
  8. Copyright 2012 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_SAME_INSTANCE_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_UTIL_SAME_INSTANCE_HPP_INCLUDED
  15. namespace boost {
  16. namespace numeric {
  17. namespace odeint {
  18. template< class T1 , class T2 , class Enabler=void >
  19. struct same_instance_impl
  20. {
  21. static bool same_instance( const T1& /* x1 */ , const T2& /* x2 */ )
  22. {
  23. return false;
  24. }
  25. };
  26. template< class T >
  27. struct same_instance_impl< T , T >
  28. {
  29. static bool same_instance( const T &x1 , const T &x2 )
  30. {
  31. // check pointers
  32. return (&x1 == &x2);
  33. }
  34. };
  35. template< class T1 , class T2 >
  36. bool same_instance( const T1 &x1 , const T2 &x2 )
  37. {
  38. return same_instance_impl< T1 , T2 >::same_instance( x1 , x2 );
  39. }
  40. } // namespace odeint
  41. } // namespace numeric
  42. } // namespace boost
  43. #endif