Simplified code.

[SVN r34384]
This commit is contained in:
John Maddock
2006-06-24 11:31:19 +00:00
parent 0dc11c2f23
commit 564e4029d0

View File

@ -211,45 +211,37 @@ namespace boost {
// operator[] // operator[]
reference operator[](size_type i) reference operator[](size_type i)
{ {
BOOST_ASSERT( "out of range" ); return failed_rangecheck();
failed_rangecheck();
return null_item();
} }
const_reference operator[](size_type i) const const_reference operator[](size_type i) const
{ {
BOOST_ASSERT( "out of range" ); return failed_rangecheck();
failed_rangecheck();
return null_item();
} }
// at() with range check // at() with range check
reference at(size_type i) { failed_rangecheck(); return null_item(); } reference at(size_type i) { return failed_rangecheck(); }
const_reference at(size_type i) const { failed_rangecheck(); return null_item(); } const_reference at(size_type i) const { return failed_rangecheck(); }
// front() and back() // front() and back()
reference front() reference front()
{ {
failed_rangecheck(); return failed_rangecheck();
return null_item();
} }
const_reference front() const const_reference front() const
{ {
failed_rangecheck(); return failed_rangecheck();
return null_item();
} }
reference back() reference back()
{ {
failed_rangecheck(); return failed_rangecheck();
return null_item();
} }
const_reference back() const const_reference back() const
{ {
failed_rangecheck(); return failed_rangecheck();
return null_item();
} }
// size is constant // size is constant
@ -278,20 +270,17 @@ namespace boost {
void assign (const T& ) { } void assign (const T& ) { }
// check range (may be private because it is static) // check range (may be private because it is static)
static void failed_rangecheck () { static reference failed_rangecheck () {
std::range_error e("attempt to access element of an empty array"); std::range_error e("attempt to access element of an empty array");
boost::throw_exception(e); boost::throw_exception(e);
//
// We need to return something here to keep
// some compilers happy: however we will never
// actually get here....
//
static T placeholder;
return placeholder;
} }
static reference null_item()
{
//
// This function must exist to allow our various interfaces to
// actually compile, however it will never be called, because
// an exception will always be thrown before we get here.
//
static T placeholder;
return placeholder;
}
}; };
#endif #endif