summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/__tuple18
-rw-r--r--libcxx/include/array35
-rw-r--r--libcxx/include/tuple18
-rw-r--r--libcxx/include/utility24
-rw-r--r--libcxx/test/containers/sequences/array/array.size/size.pass.cpp8
-rw-r--r--libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp24
-rw-r--r--libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp10
-rw-r--r--libcxx/test/containers/sequences/array/at.pass.cpp67
-rw-r--r--libcxx/test/containers/sequences/array/front_back.pass.cpp62
-rw-r--r--libcxx/test/containers/sequences/array/indexing.pass.cpp60
-rw-r--r--libcxx/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp6
-rw-r--r--libcxx/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp18
12 files changed, 299 insertions, 51 deletions
diff --git a/libcxx/include/__tuple b/libcxx/include/__tuple
index 1213262daa2..9a6b6e09fb1 100644
--- a/libcxx/include/__tuple
+++ b/libcxx/include/__tuple
@@ -79,47 +79,47 @@ template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
template <size_t _Ip, class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(tuple<_Tp...>&) _NOEXCEPT;
template <size_t _Ip, class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(const tuple<_Tp...>&) _NOEXCEPT;
template <size_t _Ip, class ..._Tp>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(tuple<_Tp...>&&) _NOEXCEPT;
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(pair<_T1, _T2>&) _NOEXCEPT;
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>&) _NOEXCEPT;
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(pair<_T1, _T2>&&) _NOEXCEPT;
template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp&
get(array<_Tp, _Size>&) _NOEXCEPT;
template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _Tp&
get(const array<_Tp, _Size>&) _NOEXCEPT;
template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp&&
get(array<_Tp, _Size>&&) _NOEXCEPT;
diff --git a/libcxx/include/array b/libcxx/include/array
index bcf53478677..86d1fc0be69 100644
--- a/libcxx/include/array
+++ b/libcxx/include/array
@@ -59,14 +59,14 @@ struct array
// element access:
reference operator[](size_type n);
- const_reference operator[](size_type n) const;
- const_reference at(size_type n) const;
+ const_reference operator[](size_type n) const; // constexpr in C++14
+ const_reference at(size_type n) const; // constexpr in C++14
reference at(size_type n);
reference front();
- const_reference front() const;
+ const_reference front() const; // constexpr in C++14
reference back();
- const_reference back() const;
+ const_reference back() const; // constexpr in C++14
T* data() noexcept;
const T* data() const noexcept;
@@ -92,9 +92,9 @@ template <class T> class tuple_size;
template <int I, class T> class tuple_element;
template <class T, size_t N> struct tuple_size<array<T, N>>;
template <int I, class T, size_t N> struct tuple_element<I, array<T, N>>;
-template <int I, class T, size_t N> T& get(array<T, N>&) noexcept;
-template <int I, class T, size_t N> const T& get(const array<T, N>&) noexcept;
-template <int I, class T, size_t N> T&& get(array<T, N>&&) noexcept;
+template <int I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
+template <int I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
+template <int I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
} // std
@@ -181,14 +181,14 @@ struct _LIBCPP_TYPE_VIS array
// element access:
_LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __elems_[__n];}
- _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __elems_[__n];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference operator[](size_type __n) const {return __elems_[__n];}
reference at(size_type __n);
- const_reference at(size_type __n) const;
+ _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
_LIBCPP_INLINE_VISIBILITY reference front() {return __elems_[0];}
- _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __elems_[0];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
_LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];}
- _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY
value_type* data() _NOEXCEPT {return __elems_;}
@@ -210,6 +210,7 @@ array<_Tp, _Size>::at(size_type __n)
}
template <class _Tp, size_t _Size>
+_LIBCPP_CONSTEXPR_AFTER_CXX11
typename array<_Tp, _Size>::const_reference
array<_Tp, _Size>::at(size_type __n) const
{
@@ -306,32 +307,32 @@ public:
};
template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY inline
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp&
get(array<_Tp, _Size>& __a) _NOEXCEPT
{
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
- return __a[_Ip];
+ return __a.__elems_[_Ip];
}
template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY inline
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11
const _Tp&
get(const array<_Tp, _Size>& __a) _NOEXCEPT
{
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
- return __a[_Ip];
+ return __a.__elems_[_Ip];
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <size_t _Ip, class _Tp, size_t _Size>
-_LIBCPP_INLINE_VISIBILITY inline
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp&&
get(array<_Tp, _Size>&& __a) _NOEXCEPT
{
static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
- return _VSTD::move(__a[_Ip]);
+ return _VSTD::move(__a.__elems_[_Ip]);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index c7a1c1433c2..5d5debfac6a 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -86,13 +86,13 @@ template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
// 20.4.1.5, element access:
template <intsize_t I, class... T>
typename tuple_element<I, tuple<T...>>::type&
- get(tuple<T...>&) noexcept;
+ get(tuple<T...>&) noexcept; // constexpr in C++14
template <intsize_t I, class... T>
typename tuple_element<I, tuple<T...>>::type const&
- get(const tuple<T...>&) noexcept;
+ get(const tuple<T...>&) noexcept; // constexpr in C++14
template <intsize_t I, class... T>
typename tuple_element<I, tuple<T...>>::type&&
- get(tuple<T...>&&) noexcept;
+ get(tuple<T...>&&) noexcept; // constexpr in C++14
template <class T1, class... T>
constexpr T1& get(tuple<T...>&) noexcept; // C++14
@@ -546,11 +546,11 @@ class _LIBCPP_TYPE_VIS tuple
base base_;
- template <size_t _Jp, class ..._Up> friend
+ template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
- template <size_t _Jp, class ..._Up> friend
+ template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
- template <size_t _Jp, class ..._Up> friend
+ template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
public:
@@ -763,7 +763,7 @@ swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
// get
template <size_t _Ip, class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(tuple<_Tp...>& __t) _NOEXCEPT
{
@@ -772,7 +772,7 @@ get(tuple<_Tp...>& __t) _NOEXCEPT
}
template <size_t _Ip, class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(const tuple<_Tp...>& __t) _NOEXCEPT
{
@@ -781,7 +781,7 @@ get(const tuple<_Tp...>& __t) _NOEXCEPT
}
template <size_t _Ip, class ..._Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(tuple<_Tp...>&& __t) _NOEXCEPT
{
diff --git a/libcxx/include/utility b/libcxx/include/utility
index 2d2670d6924..d36cf9dd766 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -107,15 +107,15 @@ template <class T1, class T2> struct tuple_element<1, std::pair<T1, T2> >;
template<size_t I, class T1, class T2>
typename tuple_element<I, std::pair<T1, T2> >::type&
- get(std::pair<T1, T2>&) noexcept;
+ get(std::pair<T1, T2>&) noexcept; // constexpr in C++14
template<size_t I, class T1, class T2>
const typename const tuple_element<I, std::pair<T1, T2> >::type&
- get(const std::pair<T1, T2>&) noexcept;
+ get(const std::pair<T1, T2>&) noexcept; // constexpr in C++14
template<size_t I, class T1, class T2>
typename tuple_element<I, std::pair<T1, T2> >::type&&
- get(std::pair<T1, T2>&&) noexcept;
+ get(std::pair<T1, T2>&&) noexcept; // constexpr in C++14
template<class T1, class T2>
constexpr T1& get(std::pair<T1, T2>&) noexcept; // C++14
@@ -546,13 +546,13 @@ struct __get_pair<0>
{
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_T1&
get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _T1&
get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
@@ -560,7 +560,7 @@ struct __get_pair<0>
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_T1&&
get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
@@ -572,13 +572,13 @@ struct __get_pair<1>
{
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_T2&
get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _T2&
get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
@@ -586,7 +586,7 @@ struct __get_pair<1>
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_T2&&
get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
@@ -594,7 +594,7 @@ struct __get_pair<1>
};
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY inline
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(pair<_T1, _T2>& __p) _NOEXCEPT
{
@@ -602,7 +602,7 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT
}
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY inline
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>& __p) _NOEXCEPT
{
@@ -612,7 +612,7 @@ get(const pair<_T1, _T2>& __p) _NOEXCEPT
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY inline
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(pair<_T1, _T2>&& __p) _NOEXCEPT
{
diff --git a/libcxx/test/containers/sequences/array/array.size/size.pass.cpp b/libcxx/test/containers/sequences/array/array.size/size.pass.cpp
index 4078fd5ca9f..fe5a0d5c8db 100644
--- a/libcxx/test/containers/sequences/array/array.size/size.pass.cpp
+++ b/libcxx/test/containers/sequences/array/array.size/size.pass.cpp
@@ -21,12 +21,16 @@ int main()
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
assert(c.size() == 3);
+ assert(c.max_size() == 3);
+ assert(!c.empty());
}
{
typedef double T;
typedef std::array<T, 0> C;
C c = {};
assert(c.size() == 0);
+ assert(c.max_size() == 0);
+ assert(c.empty());
}
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
{
@@ -34,12 +38,16 @@ int main()
typedef std::array<T, 3> C;
constexpr C c = {1, 2, 3.5};
static_assert(c.size() == 3, "");
+ static_assert(c.max_size() == 3, "");
+ static_assert(!c.empty(), "");
}
{
typedef double T;
typedef std::array<T, 0> C;
constexpr C c = {};
static_assert(c.size() == 0, "");
+ static_assert(c.max_size() == 0, "");
+ static_assert(c.empty(), "");
}
#endif
}
diff --git a/libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp b/libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp
index 9820babcd24..d9e242cd420 100644
--- a/libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp
+++ b/libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp
@@ -14,6 +14,16 @@
#include <array>
#include <cassert>
+#if __cplusplus > 201103L
+struct S {
+ std::array<int, 3> a;
+ int k;
+ constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
+ };
+
+constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
+#endif
+
int main()
{
{
@@ -25,4 +35,18 @@ int main()
assert(c[1] == 5.5);
assert(c[2] == 3.5);
}
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+ static_assert(std::get<0>(c) == 1, "");
+ static_assert(std::get<1>(c) == 2, "");
+ static_assert(std::get<2>(c) == 3.5, "");
+ }
+ {
+ static_assert(S().k == 3, "");
+ static_assert(std::get<1>(getArr()) == 4, "");
+ }
+#endif
}
diff --git a/libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp b/libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp
index 6ede8f0c784..1cbdfa4ff39 100644
--- a/libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp
+++ b/libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp
@@ -24,4 +24,14 @@ int main()
assert(std::get<1>(c) == 2);
assert(std::get<2>(c) == 3.5);
}
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr const C c = {1, 2, 3.5};
+ static_assert(std::get<0>(c) == 1, "");
+ static_assert(std::get<1>(c) == 2, "");
+ static_assert(std::get<2>(c) == 3.5, "");
+ }
+#endif
}
diff --git a/libcxx/test/containers/sequences/array/at.pass.cpp b/libcxx/test/containers/sequences/array/at.pass.cpp
new file mode 100644
index 00000000000..b5cf8a5aaa8
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/at.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::reference r1 = c.at(0);
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c.front() == 5.5);
+
+ C::reference r2 = c.at(2);
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c.back() == 7.5);
+
+ try { (void) c.at(3); }
+ catch (const std::out_of_range &) {}
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c.at(0);
+ assert(r1 == 1);
+
+ C::const_reference r2 = c.at(2);
+ assert(r2 == 3.5);
+
+ try { (void) c.at(3); }
+ catch (const std::out_of_range &) {}
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c.at(0);
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c.at(2);
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/containers/sequences/array/front_back.pass.cpp b/libcxx/test/containers/sequences/array/front_back.pass.cpp
new file mode 100644
index 00000000000..45a963b9947
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/front_back.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference front();
+// reference back();
+// const_reference front(); // constexpr in C++14
+// const_reference back(); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+
+ C::reference r1 = c.front();
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c[0] == 5.5);
+
+ C::reference r2 = c.back();
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c[2] == 7.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c.front();
+ assert(r1 == 1);
+
+ C::const_reference r2 = c.back();
+ assert(r2 == 3.5);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c.front();
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c.back();
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/containers/sequences/array/indexing.pass.cpp b/libcxx/test/containers/sequences/array/indexing.pass.cpp
new file mode 100644
index 00000000000..e4dda0dc5cf
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/indexing.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::reference r1 = c[0];
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c.front() == 5.5);
+
+ C::reference r2 = c[2];
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c.back() == 7.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c[0];
+ assert(r1 == 1);
+ C::const_reference r2 = c[2];
+ assert(r2 == 3.5);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c[0];
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c[2];
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp b/libcxx/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
index 43e70ea5233..fcda3664d9b 100644
--- a/libcxx/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
+++ b/libcxx/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
@@ -31,10 +31,8 @@ int main()
{
typedef std::pair<int, short> P;
constexpr P p1(3, 4);
- static_assert(p1.first == 3, "" ); // for now!
- static_assert(p1.second == 4, "" ); // for now!
-// static_assert(std::get<0>(p1) == 3, "");
-// static_assert(std::get<1>(p1) == 4, "");
+ static_assert(std::get<0>(p1) == 3, "");
+ static_assert(std::get<1>(p1) == 4, "");
}
#endif
}
diff --git a/libcxx/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp b/libcxx/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
index ebfbe9e45d4..6d61c47ffbf 100644
--- a/libcxx/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
+++ b/libcxx/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
@@ -18,6 +18,16 @@
#include <utility>
#include <cassert>
+#if __cplusplus > 201103L
+struct S {
+ std::pair<int, int> a;
+ int k;
+ constexpr S() : a{1,2}, k(std::get<0>(a)) {}
+ };
+
+constexpr std::pair<int, int> getP () { return { 3, 4 }; }
+#endif
+
int main()
{
{
@@ -30,4 +40,12 @@ int main()
assert(std::get<0>(p) == 5);
assert(std::get<1>(p) == 6);
}
+
+#if __cplusplus > 201103L
+ {
+ static_assert(S().k == 1, "");
+ static_assert(std::get<1>(getP()) == 4, "");
+ }
+#endif
+
}
OpenPOWER on IntegriCloud