forked from OSchip/llvm-project
Move <dynarray> into include/experimental, and into the std::experimental namespace, since it's not part of C++14, but of an upcoming TS
llvm-svn: 194614
This commit is contained in:
parent
7ee147246f
commit
21fee96f69
|
@ -17,7 +17,7 @@
|
|||
/*
|
||||
dynarray synopsis
|
||||
|
||||
namespace std {
|
||||
namespace std { namespace experimental {
|
||||
|
||||
template< typename T >
|
||||
class dynarray
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
void fill(const T& v);
|
||||
};
|
||||
|
||||
} // std
|
||||
}} // std::experimental
|
||||
|
||||
*/
|
||||
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
namespace std { namespace experimental { inline namespace __array_extensions_v1 {
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY dynarray
|
||||
|
@ -302,9 +302,12 @@ dynarray<_Tp>::at(size_type __n) const
|
|||
return data()[__n];
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<dynarray<_Tp>, _Alloc> : true_type {};
|
||||
}}}
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
template <class _Tp, class _Alloc>
|
||||
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {};
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // if _LIBCPP_STD_VER > 11
|
|
@ -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 );
|
||||
|
|
|
@ -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; } ));
|
||||
|
||||
|
|
|
@ -17,23 +17,24 @@
|
|||
|
||||
#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 dyn_test_const ( const std::dynarray<T> &dyn ) {
|
||||
void dyn_test_const ( const dynarray<T> &dyn ) {
|
||||
const T *data = dyn.data ();
|
||||
assert ( data != NULL );
|
||||
assert ( std::equal ( dyn.begin(), dyn.end(), data ));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void dyn_test ( std::dynarray<T> &dyn ) {
|
||||
void dyn_test ( dynarray<T> &dyn ) {
|
||||
T *data = dyn.data ();
|
||||
assert ( data != NULL );
|
||||
assert ( std::equal ( dyn.begin(), dyn.end(), data ));
|
||||
|
@ -43,7 +44,7 @@ void dyn_test ( std::dynarray<T> &dyn ) {
|
|||
|
||||
template <class T>
|
||||
void test ( const T &val ) {
|
||||
typedef std::dynarray<T> dynA;
|
||||
typedef dynarray<T> dynA;
|
||||
|
||||
dynA d1 ( 4 );
|
||||
dyn_test ( d1 );
|
||||
|
|
|
@ -17,17 +17,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 T &val ) {
|
||||
typedef std::dynarray<T> dynA;
|
||||
typedef dynarray<T> dynA;
|
||||
|
||||
dynA d1 ( 4 );
|
||||
d1.fill ( val );
|
||||
|
|
|
@ -16,22 +16,24 @@
|
|||
|
||||
#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 dyn_at_fail ( std::dynarray<T> &dyn, size_t sz ) {
|
||||
void dyn_at_fail ( dynarray<T> &dyn, size_t sz ) {
|
||||
try { dyn.at (sz); }
|
||||
catch (const std::out_of_range &) { return; }
|
||||
assert ( false );
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void dyn_at_fail_const ( const std::dynarray<T> &dyn, size_t sz ) {
|
||||
void dyn_at_fail_const ( const dynarray<T> &dyn, size_t sz ) {
|
||||
try { dyn.at (sz); }
|
||||
catch (const std::out_of_range &) { return; }
|
||||
assert ( false );
|
||||
|
@ -39,7 +41,7 @@ void dyn_at_fail_const ( const std::dynarray<T> &dyn, size_t sz ) {
|
|||
|
||||
|
||||
template <class T>
|
||||
void dyn_test_const ( const std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
||||
void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
||||
const T *data = dyn.data ();
|
||||
auto it = vals.begin ();
|
||||
for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
|
||||
|
@ -53,7 +55,7 @@ void dyn_test_const ( const std::dynarray<T> &dyn, const std::initializer_list<T
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void dyn_test ( std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
||||
void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
||||
T *data = dyn.data ();
|
||||
auto it = vals.begin ();
|
||||
for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
|
||||
|
@ -69,7 +71,7 @@ void dyn_test ( std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
|||
|
||||
template <class T>
|
||||
void test ( std::initializer_list<T> vals ) {
|
||||
typedef std::dynarray<T> dynA;
|
||||
typedef dynarray<T> dynA;
|
||||
|
||||
dynA d1 ( vals );
|
||||
dyn_test ( d1, vals );
|
||||
|
|
|
@ -29,15 +29,17 @@
|
|||
|
||||
#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 dyn_test_const ( const std::dynarray<T> &dyn ) {
|
||||
void dyn_test_const ( const dynarray<T> &dyn ) {
|
||||
const T *data = dyn.data ();
|
||||
assert ( data == &*dyn.begin ());
|
||||
assert ( data == &*dyn.cbegin ());
|
||||
|
@ -59,7 +61,7 @@ void dyn_test_const ( const std::dynarray<T> &dyn ) {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void dyn_test ( std::dynarray<T> &dyn ) {
|
||||
void dyn_test ( dynarray<T> &dyn ) {
|
||||
T *data = dyn.data ();
|
||||
assert ( data == &*dyn.begin ());
|
||||
assert ( data == &*dyn.cbegin ());
|
||||
|
@ -83,7 +85,7 @@ void dyn_test ( std::dynarray<T> &dyn ) {
|
|||
|
||||
template <class T>
|
||||
void test ( const T &val ) {
|
||||
typedef std::dynarray<T> dynA;
|
||||
typedef dynarray<T> dynA;
|
||||
|
||||
dynA d1 ( 4 );
|
||||
dyn_test ( d1 );
|
||||
|
|
|
@ -17,15 +17,17 @@
|
|||
|
||||
#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 dyn_test ( const std::dynarray<T> &dyn, size_t sz ) {
|
||||
void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
|
||||
assert ( dyn.size () == sz );
|
||||
assert ( dyn.max_size () == sz );
|
||||
assert ( dyn.empty () == ( sz == 0 ));
|
||||
|
@ -33,7 +35,7 @@ void dyn_test ( const std::dynarray<T> &dyn, size_t sz ) {
|
|||
|
||||
template <class T>
|
||||
void test ( std::initializer_list<T> vals ) {
|
||||
typedef std::dynarray<T> dynA;
|
||||
typedef dynarray<T> dynA;
|
||||
|
||||
dynA d1 ( vals );
|
||||
dyn_test ( d1, vals.size ());
|
||||
|
|
|
@ -19,22 +19,24 @@
|
|||
|
||||
#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 dyn_test_const ( const std::dynarray<T> &dyn ) {
|
||||
void dyn_test_const ( const dynarray<T> &dyn ) {
|
||||
const T *data = dyn.data ();
|
||||
assert ( *data == dyn.front ());
|
||||
assert ( *(data + dyn.size() - 1 ) == dyn.back ());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void dyn_test ( std::dynarray<T> &dyn ) {
|
||||
void dyn_test ( dynarray<T> &dyn ) {
|
||||
T *data = dyn.data ();
|
||||
assert ( *data == dyn.front ());
|
||||
assert ( *(data + dyn.size() - 1 ) == dyn.back ());
|
||||
|
@ -43,7 +45,7 @@ void dyn_test ( std::dynarray<T> &dyn ) {
|
|||
|
||||
template <class T>
|
||||
void test ( const T &val ) {
|
||||
typedef std::dynarray<T> dynA;
|
||||
typedef dynarray<T> dynA;
|
||||
|
||||
dynA d1 ( 4 );
|
||||
dyn_test ( d1 );
|
||||
|
|
|
@ -16,15 +16,17 @@
|
|||
|
||||
#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 dyn_test_const ( const std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
||||
void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
||||
const T *data = dyn.data ();
|
||||
auto it = vals.begin ();
|
||||
for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
|
||||
|
@ -34,7 +36,7 @@ void dyn_test_const ( const std::dynarray<T> &dyn, const std::initializer_list<T
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void dyn_test ( std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
||||
void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
||||
T *data = dyn.data ();
|
||||
auto it = vals.begin ();
|
||||
for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
|
||||
|
@ -46,7 +48,7 @@ void dyn_test ( std::dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
|
|||
|
||||
template <class T>
|
||||
void test ( std::initializer_list<T> vals ) {
|
||||
typedef std::dynarray<T> dynA;
|
||||
typedef dynarray<T> dynA;
|
||||
|
||||
dynA d1 ( vals );
|
||||
dyn_test ( d1, vals );
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <dynarray>
|
||||
#include <experimental/dynarray>
|
||||
#include "../../../test_allocator.h"
|
||||
|
||||
using std::experimental::dynarray;
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert ( std::uses_allocator<std::dynarray<int>, test_allocator<int>>::value, "" );
|
||||
static_assert ( std::uses_allocator<dynarray<int>, test_allocator<int>>::value, "" );
|
||||
}
|
||||
#else
|
||||
int main() {}
|
||||
|
|
|
@ -20,17 +20,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 ( ) {
|
||||
typedef std::dynarray<T> dynA;
|
||||
typedef dynarray<T> dynA;
|
||||
|
||||
dynA d1 ( 0 );
|
||||
assert ( d1.size() == 0 );
|
||||
|
|
Loading…
Reference in New Issue