[cfe-commits] [libcxx] r156308 - in /libcxx/trunk/include: __bit_reference bitset vector
Howard Hinnant
hhinnant at apple.com
Mon May 7 09:50:39 PDT 2012
Author: hhinnant
Date: Mon May 7 11:50:38 2012
New Revision: 156308
URL: http://llvm.org/viewvc/llvm-project?rev=156308&view=rev
Log:
SFINAE __bit_iterator such that it will only get instantiated with a container that has the nested type __storage_type. This prevents accidental instantiation such as in http://llvm.org/bugs/show_bug.cgi?id=12755. This fixes http://llvm.org/bugs/show_bug.cgi?id=12755.
Modified:
libcxx/trunk/include/__bit_reference
libcxx/trunk/include/bitset
libcxx/trunk/include/vector
Modified: libcxx/trunk/include/__bit_reference
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__bit_reference?rev=156308&r1=156307&r2=156308&view=diff
==============================================================================
--- libcxx/trunk/include/__bit_reference (original)
+++ libcxx/trunk/include/__bit_reference Mon May 7 11:50:38 2012
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Cp, bool _IsConst> class __bit_iterator;
+template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> class __bit_iterator;
template <class _Cp> class __bit_const_reference;
template <class _Tp>
@@ -1057,7 +1057,8 @@
return __equal_unaligned(__first1, __last1, __first2);
}
-template <class _Cp, bool _IsConst>
+template <class _Cp, bool _IsConst,
+ typename _Cp::__storage_type>
class __bit_iterator
{
public:
Modified: libcxx/trunk/include/bitset
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/bitset?rev=156308&r1=156307&r2=156308&view=diff
==============================================================================
--- libcxx/trunk/include/bitset (original)
+++ libcxx/trunk/include/bitset Mon May 7 11:50:38 2012
@@ -148,9 +148,9 @@
public:
typedef ptrdiff_t difference_type;
typedef size_t size_type;
+ typedef size_type __storage_type;
protected:
typedef __bitset __self;
- typedef size_type __storage_type;
typedef __storage_type* __storage_pointer;
typedef const __storage_type* __const_storage_pointer;
static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
@@ -406,9 +406,9 @@
public:
typedef ptrdiff_t difference_type;
typedef size_t size_type;
+ typedef size_type __storage_type;
protected:
typedef __bitset __self;
- typedef size_type __storage_type;
typedef __storage_type* __storage_pointer;
typedef const __storage_type* __const_storage_pointer;
static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
@@ -549,9 +549,9 @@
public:
typedef ptrdiff_t difference_type;
typedef size_t size_type;
+ typedef size_type __storage_type;
protected:
typedef __bitset __self;
- typedef size_type __storage_type;
typedef __storage_type* __storage_pointer;
typedef const __storage_type* __const_storage_pointer;
static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
Modified: libcxx/trunk/include/vector
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=156308&r1=156307&r2=156308&view=diff
==============================================================================
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Mon May 7 11:50:38 2012
@@ -1970,6 +1970,7 @@
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __alloc_traits::size_type size_type;
typedef typename __alloc_traits::difference_type difference_type;
+ typedef size_type __storage_type;
typedef __bit_iterator<vector, false> pointer;
typedef __bit_iterator<vector, true> const_pointer;
#ifdef _LIBCPP_DEBUG
@@ -1991,7 +1992,6 @@
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
private:
- typedef size_type __storage_type;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__storage_type>
More information about the cfe-commits
mailing list