templated constructors assertion

[SVN r2704]
This commit is contained in:
Jan Gaspar
2005-08-29 14:21:40 +00:00
parent 849b2ced7c
commit 5225b3667c
2 changed files with 42 additions and 21 deletions

View File

@@ -14,37 +14,55 @@
#endif
#include <boost/detail/workaround.hpp>
#include <boost/type_traits/is_convertible.hpp>
// 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 <boost/assert.hpp>
#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 <boost/assert.hpp>
#define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr)
#else
#include <boost/static_assert.hpp>
#include <boost/detail/iterator.hpp>
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \
BOOST_STATIC_ASSERT((is_convertible<typename detail::iterator_traits<Iterator>::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 <boost/static_assert.hpp>
#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 <boost/detail/iterator.hpp>
#include <boost/type_traits/is_convertible.hpp>
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \
BOOST_CB_STATIC_ASSERT((is_convertible<typename detail::iterator_traits<Iterator>::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)

View File

@@ -13,13 +13,13 @@
#pragma once
#endif
#include <boost/limits.hpp>
#include <boost/call_traits.hpp>
#include <boost/concept_check.hpp>
#include <boost/throw_exception.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <algorithm>
#include <limits>
#include <utility>
#include <deque>
#if !defined(BOOST_NO_EXCEPTIONS)
@@ -1215,7 +1215,8 @@ private:
//! Specialized assign method.
template <class InputIterator>
void assign(InputIterator first, InputIterator last, std::input_iterator_tag) {
std::deque<value_type> tmp(first, last); // won't compile if the STL implementation doesn't provide templated iterator constructor
BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS;
std::deque<value_type> tmp(first, last);
do_assign(tmp.size(), assign_range<BOOST_DEDUCED_TYPENAME std::deque<value_type>::iterator>(tmp.begin(), tmp.end(), m_alloc));
}