Move <dynarray> into include/experimental, and into the std::experimental namespace, since it's not part of C++14, but of an upcoming TS

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@194614 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2013-11-13 22:44:48 +00:00
parent 525a0fb982
commit 6b7c2aeb00
12 changed files with 68 additions and 46 deletions

View File

@@ -25,7 +25,7 @@
#if _LIBCPP_STD_VER > 11
#include <dynarray>
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
@@ -33,15 +33,17 @@
#include <string>
#include "../../../test_allocator.h"
using std::experimental::dynarray;
template <class T, class Allocator>
void check_allocator ( const std::dynarray<T> &dyn, const Allocator &alloc ) {
void check_allocator ( const dynarray<T> &dyn, const Allocator &alloc ) {
for ( int i = 0; i < dyn.size (); ++i )
assert ( dyn[i].get_allocator() == alloc );
}
template <class T, class Allocator>
void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
typedef std::dynarray<T> dynA;
typedef dynarray<T> dynA;
dynA d1 ( vals, alloc );
assert ( d1.size () == vals.size() );
@@ -52,7 +54,7 @@ void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
template <class T, class Allocator>
void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
typedef std::dynarray<T> dynA;
typedef dynarray<T> dynA;
dynA d1 ( 4, alloc1 );
assert ( d1.size () == 4 );

View File

@@ -21,16 +21,18 @@
#if _LIBCPP_STD_VER > 11
#include <dynarray>
#include <experimental/dynarray>
#include <cassert>
#include <algorithm>
#include <complex>
#include <string>
using std::experimental::dynarray;
template <class T>
void test ( const std::initializer_list<T> &vals ) {
typedef std::dynarray<T> dynA;
typedef dynarray<T> dynA;
dynA d1 ( vals );
assert ( d1.size () == vals.size() );
@@ -40,7 +42,7 @@ void test ( const std::initializer_list<T> &vals ) {
template <class T>
void test ( const T &val ) {
typedef std::dynarray<T> dynA;
typedef dynarray<T> dynA;
dynA d1 ( 4 );
assert ( d1.size () == 4 );
@@ -56,13 +58,13 @@ void test ( const T &val ) {
}
void test_bad_length () {
try { std::dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
catch ( std::bad_array_length & ) { return ; }
assert ( false );
}
void test_bad_alloc () {
try { std::dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) - 1 ); }
try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) - 1 ); }
catch ( std::bad_alloc & ) { return ; }
assert ( false );
}
@@ -81,7 +83,7 @@ int main()
std::string("5"), std::string("8")} );
// Make sure we don't pick up the Allocator version here
std::dynarray<long> d1 ( 20, 3 );
dynarray<long> d1 ( 20, 3 );
assert ( d1.size() == 20 );
assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } ));