forked from boostorg/array
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f017dac435 | |||
| 567ba40840 | |||
| 29700ff270 | |||
| b147799665 | |||
| acef60446a | |||
| 3d9f39814c | |||
| 89f09e33f1 |
@@ -16,3 +16,6 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
* Added `noexcept` and `constexpr` as appropriate.
|
||||
* Marked obsolete functions as deprecated.
|
||||
* Removed obsolete compiler workarounds.
|
||||
* Changed `array<T, 0>::begin()`, `cbegin()`, `end()`, `cend()` to return `nullptr`, enabling `constexpr`.
|
||||
This matches the behavior of `std::array`.
|
||||
* Removed local `hash_value` overload; `boost::hash` supports array-like types natively.
|
||||
|
||||
+8
-14
@@ -195,6 +195,8 @@ namespace boost {
|
||||
|
||||
template< class T >
|
||||
class array< T, 0 > {
|
||||
public:
|
||||
struct {} elems; // enables initialization with = {{}}
|
||||
|
||||
public:
|
||||
// type definitions
|
||||
@@ -207,13 +209,13 @@ namespace boost {
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// iterator support
|
||||
iterator begin() BOOST_NOEXCEPT { return iterator( reinterpret_cast< T * >( this ) ); }
|
||||
const_iterator begin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
||||
const_iterator cbegin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
||||
BOOST_CXX14_CONSTEXPR iterator begin() BOOST_NOEXCEPT { return data(); }
|
||||
BOOST_CONSTEXPR const_iterator begin() const BOOST_NOEXCEPT { return data(); }
|
||||
BOOST_CONSTEXPR const_iterator cbegin() const BOOST_NOEXCEPT { return data(); }
|
||||
|
||||
iterator end() BOOST_NOEXCEPT { return begin(); }
|
||||
const_iterator end() const BOOST_NOEXCEPT { return begin(); }
|
||||
const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); }
|
||||
BOOST_CXX14_CONSTEXPR iterator end() BOOST_NOEXCEPT { return begin(); }
|
||||
BOOST_CONSTEXPR const_iterator end() const BOOST_NOEXCEPT { return begin(); }
|
||||
BOOST_CONSTEXPR const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); }
|
||||
|
||||
// reverse iterator support
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
@@ -395,14 +397,6 @@ namespace boost {
|
||||
return arg.elems;
|
||||
}
|
||||
|
||||
template <class It> std::size_t hash_range(It, It);
|
||||
|
||||
template<class T, std::size_t N>
|
||||
std::size_t hash_value(const array<T,N>& arr)
|
||||
{
|
||||
return boost::hash_range(arr.begin(), arr.end());
|
||||
}
|
||||
|
||||
template <size_t Idx, typename T, size_t N>
|
||||
BOOST_CXX14_CONSTEXPR T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" );
|
||||
|
||||
+6
-1
@@ -44,7 +44,12 @@ void RunTests()
|
||||
BOOST_TEST ( const_test_case.begin() == const_test_case.end());
|
||||
BOOST_TEST ( const_test_case.cbegin() == const_test_case.cend());
|
||||
|
||||
BOOST_TEST ( test_case.begin() != const_test_case.begin() );
|
||||
// BOOST_TEST ( test_case.begin() != const_test_case.begin() );
|
||||
//
|
||||
// TR1 specified that begin() must return a unique value for zero-sized
|
||||
// arrays. However, this makes constexpr unimplementable, and all standard
|
||||
// libraries have converged on using nullptr instead (see LWG issue 2157.)
|
||||
|
||||
if( test_case.data() == const_test_case.data() ) {
|
||||
// Value of data is unspecified in TR1, so no requirement this test pass or fail
|
||||
// However, it must compile!
|
||||
|
||||
@@ -44,11 +44,11 @@ template<class T> void test4()
|
||||
|
||||
int main()
|
||||
{
|
||||
// test1<int, 0>();
|
||||
test1<int, 0>();
|
||||
test1<int, 1>();
|
||||
test1<int, 7>();
|
||||
|
||||
// test1<int const, 0>();
|
||||
test1<int const, 0>();
|
||||
test1<int const, 1>();
|
||||
test1<int const, 7>();
|
||||
|
||||
|
||||
@@ -46,11 +46,11 @@ template<class T> void test4()
|
||||
|
||||
int main()
|
||||
{
|
||||
// test1<int, 0>();
|
||||
test1<int, 0>();
|
||||
test1<int, 1>();
|
||||
test1<int, 7>();
|
||||
|
||||
// test1<int const, 0>();
|
||||
test1<int const, 0>();
|
||||
test1<int const, 1>();
|
||||
test1<int const, 7>();
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ template<class T> void test4()
|
||||
|
||||
template<class T> void test5()
|
||||
{
|
||||
// constexpr boost::array<T, 0> a = {{}};
|
||||
constexpr boost::array<T, 0> a = {{}};
|
||||
(void)a;
|
||||
}
|
||||
|
||||
template<class T> void test6()
|
||||
|
||||
@@ -94,11 +94,11 @@ template<class T> void test2()
|
||||
|
||||
int main()
|
||||
{
|
||||
// test<int, 0>();
|
||||
test<int, 0>();
|
||||
test<int, 1>();
|
||||
test<int, 7>();
|
||||
|
||||
// test<int const, 0>();
|
||||
test<int const, 0>();
|
||||
test<int const, 1>();
|
||||
test<int const, 7>();
|
||||
|
||||
|
||||
@@ -39,20 +39,17 @@ template<class T> void test2()
|
||||
{
|
||||
constexpr boost::array<T, 0> a = {};
|
||||
|
||||
// iterator access is not constexpr for boost::array<T, 0>
|
||||
// it is for std::array<T, 0>, though, so we should change it
|
||||
|
||||
STATIC_ASSERT( a.begin() == a.end() );
|
||||
STATIC_ASSERT( a.cbegin() == a.cend() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// test1<int, 0>();
|
||||
test1<int, 0>();
|
||||
test1<int, 1>();
|
||||
test1<int, 7>();
|
||||
|
||||
// test2<int>();
|
||||
test2<int>();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -76,11 +76,11 @@ template<class T, std::size_t N> void test()
|
||||
|
||||
int main()
|
||||
{
|
||||
// test<int, 0>();
|
||||
test<int, 0>();
|
||||
test<int, 1>();
|
||||
test<int, 7>();
|
||||
|
||||
// test<int const, 0>();
|
||||
test<int const, 0>();
|
||||
test<int const, 1>();
|
||||
test<int const, 7>();
|
||||
|
||||
|
||||
@@ -49,11 +49,11 @@ template<class T, std::size_t N> void test3()
|
||||
|
||||
int main()
|
||||
{
|
||||
// test1<int, 0>();
|
||||
test1<int, 0>();
|
||||
test1<int, 1>();
|
||||
test1<int, 7>();
|
||||
|
||||
// test1<int const, 0>();
|
||||
test1<int const, 0>();
|
||||
test1<int const, 1>();
|
||||
test1<int const, 7>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user