forked from boostorg/array
Uncomment BOOST_CONSTEXPR; update and enable test/array_constexpr.cpp
This commit is contained in:
@ -117,14 +117,14 @@ namespace boost {
|
|||||||
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const
|
BOOST_CONSTEXPR const_reference operator[](size_type i) const
|
||||||
{
|
{
|
||||||
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// at() with range check
|
// at() with range check
|
||||||
reference at(size_type i) { return rangecheck(i), elems[i]; }
|
reference at(size_type i) { return rangecheck(i), elems[i]; }
|
||||||
/*BOOST_CONSTEXPR*/ const_reference at(size_type i) const { return rangecheck(i), elems[i]; }
|
BOOST_CONSTEXPR const_reference at(size_type i) const { return rangecheck(i), elems[i]; }
|
||||||
|
|
||||||
// front() and back()
|
// front() and back()
|
||||||
reference front()
|
reference front()
|
||||||
@ -246,14 +246,14 @@ namespace boost {
|
|||||||
return failed_rangecheck();
|
return failed_rangecheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*BOOST_CONSTEXPR*/ const_reference operator[](size_type /*i*/) const
|
BOOST_CONSTEXPR const_reference operator[](size_type /*i*/) const
|
||||||
{
|
{
|
||||||
return failed_rangecheck();
|
return failed_rangecheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
// at() with range check
|
// at() with range check
|
||||||
reference at(size_type /*i*/) { return failed_rangecheck(); }
|
reference at(size_type /*i*/) { return failed_rangecheck(); }
|
||||||
/*BOOST_CONSTEXPR*/ const_reference at(size_type /*i*/) const { return failed_rangecheck(); }
|
BOOST_CONSTEXPR const_reference at(size_type /*i*/) const { return failed_rangecheck(); }
|
||||||
|
|
||||||
// front() and back()
|
// front() and back()
|
||||||
reference front()
|
reference front()
|
||||||
|
@ -18,7 +18,7 @@ run array5.cpp ;
|
|||||||
run array6.cpp ;
|
run array6.cpp ;
|
||||||
run array7.cpp ;
|
run array7.cpp ;
|
||||||
|
|
||||||
# run array_constexpr.cpp ;
|
compile array_constexpr.cpp ;
|
||||||
|
|
||||||
compile-fail array_getfail1.cpp ;
|
compile-fail array_getfail1.cpp ;
|
||||||
compile-fail array_getfail2.cpp ;
|
compile-fail array_getfail2.cpp ;
|
||||||
|
@ -5,27 +5,15 @@
|
|||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
#include <algorithm>
|
#include <boost/config.hpp>
|
||||||
#ifndef BOOST_NO_CXX11_HDR_ARRAY
|
|
||||||
#include <array>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_CXX11_CONSTEXPR
|
#ifndef BOOST_NO_CXX11_CONSTEXPR
|
||||||
|
|
||||||
constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
|
constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }};
|
||||||
constexpr std::array<int, 10> arr_std {{ 0,1,2,3,4,5,6,7,8,9 }};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void sink ( T t ) {}
|
|
||||||
|
|
||||||
template <typename T, size_t N>
|
|
||||||
void sink ( boost::array<T,N> &arr ) {}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// constexpr int two = arr_std.at (2);
|
|
||||||
constexpr int three = arr.at (3);
|
constexpr int three = arr.at (3);
|
||||||
int whatever [ arr.at(4) ];
|
int whatever [ arr.at(4) ];
|
||||||
(void)three;
|
(void)three;
|
||||||
@ -33,7 +21,9 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else // no constexpr means no constexpr tests!
|
#else // no constexpr means no constexpr tests!
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user