circular_buffer.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Circular buffer library header file.
  2. // Copyright (c) 2003-2008 Jan Gaspar
  3. // Use, modification, and distribution is subject to the Boost Software
  4. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. // See www.boost.org/libs/circular_buffer for documentation.
  7. #if !defined(BOOST_CIRCULAR_BUFFER_HPP)
  8. #define BOOST_CIRCULAR_BUFFER_HPP
  9. #if defined(_MSC_VER) && _MSC_VER >= 1200
  10. #pragma once
  11. #endif
  12. #include <boost/circular_buffer_fwd.hpp>
  13. #include <boost/detail/workaround.hpp>
  14. // BOOST_CB_ENABLE_DEBUG: Debug support control.
  15. #if defined(NDEBUG) || defined(BOOST_CB_DISABLE_DEBUG)
  16. #define BOOST_CB_ENABLE_DEBUG 0
  17. #else
  18. #define BOOST_CB_ENABLE_DEBUG 1
  19. #endif
  20. // BOOST_CB_ASSERT: Runtime assertion.
  21. #if BOOST_CB_ENABLE_DEBUG
  22. #include <boost/assert.hpp>
  23. #define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr)
  24. #else
  25. #define BOOST_CB_ASSERT(Expr) ((void)0)
  26. #endif
  27. // BOOST_CB_STATIC_ASSERT: Compile time assertion.
  28. #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  29. #define BOOST_CB_STATIC_ASSERT(Expr) ((void)0)
  30. #else
  31. #include <boost/static_assert.hpp>
  32. #define BOOST_CB_STATIC_ASSERT(Expr) BOOST_STATIC_ASSERT(Expr)
  33. #endif
  34. // BOOST_CB_IS_CONVERTIBLE: Check if Iterator::value_type is convertible to Type.
  35. #if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) || \
  36. BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  37. #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0)
  38. #else
  39. #include <boost/detail/iterator.hpp>
  40. #include <boost/type_traits/is_convertible.hpp>
  41. #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \
  42. BOOST_CB_STATIC_ASSERT((is_convertible<typename detail::iterator_traits<Iterator>::value_type, Type>::value))
  43. #endif
  44. // BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS:
  45. // Check if the STL provides templated iterator constructors for its containers.
  46. #if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
  47. #define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_CB_STATIC_ASSERT(false);
  48. #else
  49. #define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS ((void)0);
  50. #endif
  51. #include <boost/circular_buffer/debug.hpp>
  52. #include <boost/circular_buffer/details.hpp>
  53. #include <boost/circular_buffer/base.hpp>
  54. #include <boost/circular_buffer/space_optimized.hpp>
  55. #undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS
  56. #undef BOOST_CB_IS_CONVERTIBLE
  57. #undef BOOST_CB_STATIC_ASSERT
  58. #undef BOOST_CB_ASSERT
  59. #undef BOOST_CB_ENABLE_DEBUG
  60. #endif // #if !defined(BOOST_CIRCULAR_BUFFER_HPP)