This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Attachment:
vector.patch
Description: Text document
// { dg-options "-std=gnu++0x" }
// Copyright (C) 2010 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/>.
#define _GLIBCXX_DEBUG_PEDANTIC
#include <debug/vector>
#include <utility>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
// Move between debug vectors:
__gnu_debug::vector<int> a;
a.push_back(1);
int* int_ptr = &a.front();
__gnu_debug::vector<int> b(std::move(a));
VERIFY( b.size() == 1 && b[0] == 1 && &b.front() == int_ptr );
a = std::move(b);
VERIFY( a.size() == 1 && a[0] == 1 && &a.front() == int_ptr );
// Move from debug vector to normal one:
std::vector<int> c(std::move(a));
VERIFY( c.size() == 1 && c[0] == 1 && &c.front() == int_ptr );
const std::vector<int>& r(a);
VERIFY( a.capacity() == r.capacity() );
a.push_back(1);
int_ptr = &a.front();
c = std::move(a);
VERIFY( c.size() == 1 && c[0] == 1 && &c.front() == int_ptr );
// Move from normal vector to debug one:
a = std::move(c);
VERIFY( a.size() == 1 && a[0] == 1 && &a.front() == int_ptr );
VERIFY( a.capacity() >= a.size() );
c.push_back(1);
int_ptr = &c.front();
__gnu_debug::vector<int> d(std::move(c));
VERIFY( d.size() == 1 && d[0] == 1 && &d.front() == int_ptr );
VERIFY( d.capacity() >= d.size() );
}
int main(void)
{
test01();
return 0;
}
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |