forked from boostorg/array
Compare commits
4 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
47ef0218de | |||
992299f2bf | |||
e6a44cf529 | |||
111e93aa4c |
@ -118,13 +118,13 @@ namespace boost {
|
|||||||
// operator[]
|
// operator[]
|
||||||
reference operator[](size_type i)
|
reference operator[](size_type i)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( i < N && "out of range" );
|
BOOST_ASSERT_MSG( i < N, "out of range" );
|
||||||
return elems[i];
|
return elems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reference operator[](size_type i) const
|
const_reference operator[](size_type i) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( i < N && "out of range" );
|
BOOST_ASSERT_MSG( i < N, "out of range" );
|
||||||
return elems[i];
|
return elems[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,17 +368,17 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__SUNPRO_CC)
|
#if defined(__SUNPRO_CC)
|
||||||
// Trac ticket #4757; the Sun Solaris compiler can't handle
|
// Trac ticket #4757; the Sun Solaris compiler can't handle
|
||||||
// syntax like 'T(&get_c_array(boost::array<T,N>& arg))[N]'
|
// syntax like 'T(&get_c_array(boost::array<T,N>& arg))[N]'
|
||||||
//
|
//
|
||||||
// We can't just use this for all compilers, because the
|
// We can't just use this for all compilers, because the
|
||||||
// borland compilers can't handle this form.
|
// borland compilers can't handle this form.
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename T, std::size_t N> struct c_array
|
template <typename T, std::size_t N> struct c_array
|
||||||
{
|
{
|
||||||
typedef T type[N];
|
typedef T type[N];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specific for boost::array: simply returns its elems data member.
|
// Specific for boost::array: simply returns its elems data member.
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
@ -408,7 +408,7 @@ namespace boost {
|
|||||||
return arg.elems;
|
return arg.elems;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Overload for std::array, assuming that std::array will have
|
// Overload for std::array, assuming that std::array will have
|
||||||
// explicit conversion functions as discussed at the WG21 meeting
|
// explicit conversion functions as discussed at the WG21 meeting
|
||||||
|
@ -15,12 +15,11 @@
|
|||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
#include "print.hpp"
|
#include "print.hpp"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace boost;
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// create and initialize array
|
// create and initialize array
|
||||||
array<int,10> a = { { 1, 2, 3, 4, 5 } };
|
boost::array<int,10> a = { { 1, 2, 3, 4, 5 } };
|
||||||
|
|
||||||
print_elements(a);
|
print_elements(a);
|
||||||
|
|
||||||
|
@ -26,13 +26,13 @@ void RunTests()
|
|||||||
test_type test_case; // = { 1, 1, 2, 3, 5 };
|
test_type test_case; // = { 1, 1, 2, 3, 5 };
|
||||||
|
|
||||||
arr &aRef = get_c_array ( test_case );
|
arr &aRef = get_c_array ( test_case );
|
||||||
if ( &*test_case.begin () != &aRef[0] )
|
if ( &*test_case.begin () != &aRef[0] )
|
||||||
fail_test ( "Array6: Same thing not equal?(1)" );
|
fail_test ( "Array6: Same thing not equal?(1)" );
|
||||||
|
|
||||||
const arr &caRef = get_c_array ( test_case );
|
const arr &caRef = get_c_array ( test_case );
|
||||||
typename test_type::const_iterator iter = test_case.begin ();
|
typename test_type::const_iterator iter = test_case.begin ();
|
||||||
if ( &*iter != &caRef[0] )
|
if ( &*iter != &caRef[0] )
|
||||||
fail_test ( "Array6: Same thing not equal?(2)" );
|
fail_test ( "Array6: Same thing not equal?(2)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user