diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-23 01:39:17 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-23 01:39:17 +0000 |
commit | d64890c04581af07969401c844d47f37332327d2 (patch) | |
tree | 2c9a67492ce868bbbcbe2bf4aaa4bd2eba02688d /libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc | |
parent | 945e498ce8c441de3526643197e89fcba36b5d16 (diff) | |
download | gcc-d64890c04581af07969401c844d47f37332327d2.tar.gz |
2008-05-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/tr1_impl/hashtable_policy.h (_Map_base<,,
std::_Select1st<_Pair>, true,>::at): Add per DR 761.
* testsuite/23_containers/unordered_map/dr761.cc: New.
* doc/xml/manual/intro.xml: Add an entry for DR 761.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135787 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc new file mode 100644 index 00000000000..a582bc4f6ea --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/dr761.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-22 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include <unordered_map> +#include <stdexcept> +#include <testsuite_hooks.h> + +// DR 761. unordered_map needs an at() member function. +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::unordered_map<int, double> map_type; + + { + map_type m; + m[0] = 1.5; + + double& rd = m.at(0); + VERIFY( rd == 1.5 ); + try + { + m.at(1); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } + + { + map_type m; + m[1] = 2.5; + const map_type cm(m); + + const double& crd = cm.at(1); + VERIFY( crd == 2.5 ); + try + { + cm.at(0); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } +} + +int main() +{ + test01(); + return 0; +} |