diff --git a/include/boost/circular_buffer.hpp b/include/boost/circular_buffer.hpp index 2d8c019..9b880ca 100644 --- a/include/boost/circular_buffer.hpp +++ b/include/boost/circular_buffer.hpp @@ -14,37 +14,55 @@ #endif #include -#include -// Debug support control. +// BOOST_CB_ENABLE_DEBUG - debug support control. #if defined(NDEBUG) || defined(BOOST_DISABLE_CB_DEBUG) - #define BOOST_CB_ASSERT(Expr) ((void)0) #define BOOST_CB_ENABLE_DEBUG 0 #else - #include - #define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr) #define BOOST_CB_ENABLE_DEBUG 1 #endif -// The macro definition which checks if Iterator::value_type is convertible to Type. -#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || \ - BOOST_WORKAROUND(__MWERKS__, <= 0x2407) || \ - BOOST_WORKAROUND(BOOST_MSVC, <= 1300) - #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0) +// BOOST_CB_ASSERT - assertion. +#if BOOST_CB_ENABLE_DEBUG + #include + #define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr) #else - #include - #include - #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \ - BOOST_STATIC_ASSERT((is_convertible::value_type, Type>::value)); + #define BOOST_CB_ASSERT(Expr) ((void)0) #endif -// Exception handling macros. -#if !defined(BOOST_NO_EXCEPTIONS) - #define BOOST_CB_TRY try { - #define BOOST_CB_UNWIND(action) } catch(...) { action; throw; } +// BOOST_CB_STATIC_ASSERT - static assertion. +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + #define BOOST_CB_STATIC_ASSERT(Expr) ((void)0) #else + #include + #define BOOST_CB_STATIC_ASSERT(Expr) BOOST_STATIC_ASSERT(Expr) +#endif + +// BOOST_CB_IS_CONVERTIBLE - check if Iterator::value_type is convertible to Type. +#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) + #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0) +#else + #include + #include + #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \ + BOOST_CB_STATIC_ASSERT((is_convertible::value_type, Type>::value)) +#endif + +// BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS - check if the STL implements templated +// iterator constructors for containers. +#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) + #define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_CB_STATIC_ASSERT(false) +#else + #define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS ((void)0) +#endif + +// BOOST_CB_TRY and BOOST_CB_UNWIND - exception handling. +#if defined(BOOST_NO_EXCEPTIONS) #define BOOST_CB_TRY { #define BOOST_CB_UNWIND(action) } +#else + #define BOOST_CB_TRY try { + #define BOOST_CB_UNWIND(action) } catch(...) { action; throw; } #endif #include "circular_buffer_fwd.hpp" @@ -55,8 +73,10 @@ #undef BOOST_CB_UNWIND #undef BOOST_CB_TRY +#undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS #undef BOOST_CB_IS_CONVERTIBLE -#undef BOOST_CB_ENABLE_DEBUG +#undef BOOST_CB_STATIC_ASSERT #undef BOOST_CB_ASSERT +#undef BOOST_CB_ENABLE_DEBUG #endif // #if !defined(BOOST_CIRCULAR_BUFFER_HPP) diff --git a/include/boost/circular_buffer/base.hpp b/include/boost/circular_buffer/base.hpp index 1ebfafe..3303674 100644 --- a/include/boost/circular_buffer/base.hpp +++ b/include/boost/circular_buffer/base.hpp @@ -13,13 +13,13 @@ #pragma once #endif +#include #include #include #include #include #include #include -#include #include #include #if !defined(BOOST_NO_EXCEPTIONS) @@ -1215,7 +1215,8 @@ private: //! Specialized assign method. template void assign(InputIterator first, InputIterator last, std::input_iterator_tag) { - std::deque tmp(first, last); // won't compile if the STL implementation doesn't provide templated iterator constructor + BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS; + std::deque tmp(first, last); do_assign(tmp.size(), assign_range::iterator>(tmp.begin(), tmp.end(), m_alloc)); }