Hi
I had some problems when testing pretty printers while having activated concept checks. I noticed that std::deque had already the _SGIAssignableConcept check disable when using C++11 so I propose to generalize to all usages of this concept check.
Additionally it avoids the definition of a typedef, usually _Alloc_value_type, only used when concept check is activated.
Note that I plan to also commit several cleanup of empty chars with this patch, transformation of 8 spaces into tabs or removal of spaces at end of line. I attached a 'git diff -w' patch file, let me know if you want to see the complete version.
Tested under Linux x86_64. Ok to commit ? Now ? * include/bits/stl_deque.h (deque): Access allocator value_type only if concept checks are enabled. * include/bits/stl_stack.h (stack): Likewise. * include/bits/stl_vector.h (vector): Likewise. * include/bits/stl_list.h (list): Likewise and check _SGIAssignableConcept only in C++03. * include/bits/stl_map.h (map): Likewise. * include/bits/stl_set.h (set): Likewise. * include/bits/stl_multimap.h (multimap): Likewise. * include/bits/stl_multiset.h (multiset): Likewise. * include/bits/stl_queue.h (queue, priority_queue): Likewise. * include/ext/slist (slist): Likewise. François
diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index f097429..bf652d3 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -844,12 +844,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class deque : protected _Deque_base<_Tp, _Alloc> { +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Alloc::value_type _Alloc_value_type; # if __cplusplus < 201103L __glibcxx_class_requires(_Tp, _SGIAssignableConcept) # endif __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif typedef _Deque_base<_Tp, _Alloc> _Base; typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 9424aec..0f26511 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -502,10 +502,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class list : protected _List_base<_Tp, _Alloc> { +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif typedef _List_base<_Tp, _Alloc> _Base; typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index 194ce42..3033953 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -106,12 +106,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typedef _Alloc allocator_type; private: +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) +#endif public: class value_compare diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 8b37de9..7dc22a9 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -105,12 +105,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typedef _Alloc allocator_type; private: +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept) +#endif public: class value_compare diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index 871369c..60a3db8 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -94,12 +94,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typename _Alloc = std::allocator<_Key> > class multiset { +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L __glibcxx_class_requires(_Key, _SGIAssignableConcept) +# endif __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) +#endif public: // typedefs: diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h index 3a52367..c49f371 100644 --- a/libstdc++-v3/include/bits/stl_queue.h +++ b/libstdc++-v3/include/bits/stl_queue.h @@ -95,12 +95,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, typename _Sequence = deque<_Tp> > class queue { +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Sequence::value_type _Sequence_value_type; +# if __cplusplus < 201103L __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif __glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept) __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept) __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) +#endif template<typename _Tp1, typename _Seq1> friend bool @@ -418,14 +422,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename _Compare = less<typename _Sequence::value_type> > class priority_queue { +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Sequence::value_type _Sequence_value_type; +# if __cplusplus < 201103L __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +# endif __glibcxx_class_requires(_Sequence, _SequenceConcept) __glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept) __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) __glibcxx_class_requires4(_Compare, bool, _Tp, _Tp, _BinaryFunctionConcept) +#endif #if __cplusplus >= 201103L template<typename _Alloc> diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 3decaff..817bc2d 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -92,12 +92,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typename _Alloc = std::allocator<_Key> > class set { +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Alloc::value_type _Alloc_value_type; +# if __cplusplus < 201103L __glibcxx_class_requires(_Key, _SGIAssignableConcept) +# endif __glibcxx_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept) __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept) +#endif public: // typedefs: diff --git a/libstdc++-v3/include/bits/stl_stack.h b/libstdc++-v3/include/bits/stl_stack.h index 094ce65..ac59ec7 100644 --- a/libstdc++-v3/include/bits/stl_stack.h +++ b/libstdc++-v3/include/bits/stl_stack.h @@ -98,6 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, typename _Sequence = deque<_Tp> > class stack { +#ifdef _GLIBCXX_CONCEPT_CHECKS // concept requirements typedef typename _Sequence::value_type _Sequence_value_type; # if __cplusplus < 201103L @@ -105,6 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept) # endif __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept) +#endif template<typename _Tp1, typename _Seq1> friend bool diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index ffe8f6f..fb88212 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -215,12 +215,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class vector : protected _Vector_base<_Tp, _Alloc> { +#ifdef _GLIBCXX_CONCEPT_CHECKS // Concept requirements. typedef typename _Alloc::value_type _Alloc_value_type; # if __cplusplus < 201103L __glibcxx_class_requires(_Tp, _SGIAssignableConcept) # endif __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept) +#endif typedef _Vector_base<_Tp, _Alloc> _Base; typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; diff --git a/libstdc++-v3/include/ext/slist b/libstdc++-v3/include/ext/slist index 66a0a88..2e75282 100644 --- a/libstdc++-v3/include/ext/slist +++ b/libstdc++-v3/include/ext/slist @@ -291,8 +291,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template <class _Tp, class _Alloc = allocator<_Tp> > class slist : private _Slist_base<_Tp,_Alloc> { +#if __cplusplus < 201103L // concept requirements __glibcxx_class_requires(_Tp, _SGIAssignableConcept) +#endif private: typedef _Slist_base<_Tp,_Alloc> _Base;