diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2009-05-18 23:16:20 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2009-05-18 23:16:20 +0000 |
commit | cf0e6fff1dc4a636bec5f7aba7a0de2836af2e72 (patch) | |
tree | ed7a8a192ab8965cf03e0c224efbfe60ad153cd2 | |
parent | 1bb99877d3353dbb216ee90a61bd9de811387c7d (diff) | |
download | gcc-cf0e6fff1dc4a636bec5f7aba7a0de2836af2e72.zip gcc-cf0e6fff1dc4a636bec5f7aba7a0de2836af2e72.tar.gz gcc-cf0e6fff1dc4a636bec5f7aba7a0de2836af2e72.tar.bz2 |
re PR c++/40192 (Unable to use std::vector with typedef'd array types)
2009-05-18 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/40192
* include/bits/stl_construct.h (struct _Destroy_aux): Add.
(_Destroy(_ForwardIterator, _ForwardIterator)): Use the latter.
* testsuite/23_containers/vector/40192.cc: New.
From-SVN: r147680
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_construct.h | 25 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/vector/40192.cc | 28 |
3 files changed, 57 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 29c4805..ab3c32d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2009-05-18 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/40192 + * include/bits/stl_construct.h (struct _Destroy_aux): Add. + (_Destroy(_ForwardIterator, _ForwardIterator)): Use the latter. + * testsuite/23_containers/vector/40192.cc: New. + 2009-05-18 Jonathan Wakely <jwakely.gcc@gmail.com> * include/bits/stl_pair.h (swap): Do not swap rvalues. diff --git a/libstdc++-v3/include/bits/stl_construct.h b/libstdc++-v3/include/bits/stl_construct.h index 265c3ab..9df37fe 100644 --- a/libstdc++-v3/include/bits/stl_construct.h +++ b/libstdc++-v3/include/bits/stl_construct.h @@ -82,6 +82,26 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _Destroy(_Tp* __pointer) { __pointer->~_Tp(); } + template<bool> + struct _Destroy_aux + { + template<typename _ForwardIterator> + static void + __destroy(_ForwardIterator __first, _ForwardIterator __last) + { + for (; __first != __last; ++__first) + std::_Destroy(&*__first); + } + }; + + template<> + struct _Destroy_aux<true> + { + template<typename _ForwardIterator> + static void + __destroy(_ForwardIterator, _ForwardIterator) { } + }; + /** * Destroy a range of objects. If the value_type of the object has * a trivial destructor, the compiler should optimize all of this @@ -93,9 +113,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { typedef typename iterator_traits<_ForwardIterator>::value_type _Value_type; - if (!__has_trivial_destructor(_Value_type)) - for (; __first != __last; ++__first) - std::_Destroy(&*__first); + std::_Destroy_aux<__has_trivial_destructor(_Value_type)>:: + __destroy(__first, __last); } /** diff --git a/libstdc++-v3/testsuite/23_containers/vector/40192.cc b/libstdc++-v3/testsuite/23_containers/vector/40192.cc new file mode 100644 index 0000000..eff88d4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/40192.cc @@ -0,0 +1,28 @@ +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } + +// libstdc++/40192 + +#include <vector> + +void test01() +{ + typedef float float4[4]; + std::vector<float4> vals; +} |