Should _GLIBCXX_DEBUG affect tr1/array?
Jonathan Wakely
jwakely.gcc@gmail.com
Mon Jan 16 14:27:00 GMT 2012
On 16 January 2012 14:24, Jonathan Wakely wrote:
> On 16 January 2012 12:28, Edward Rosten wrote:
>>
>> I've been reading through some of the libstdc++ headers to try to
>> determine the correct way to do this.
>>
>> it like a good way might be to have:
>>
>> #ifdef _GLIBCXX_DEBUG
>> # include<debug/macros.h>
>> #endif
>>
>> Then, operator[] would become:
>> // Element access.
>> reference
>> operator[](size_type __n)
>> {
>> #ifdef _GLIBCXX_DEBUG
>> __glibcxx_check_subscript(__n);
>> #endif
>> return _M_instance[__n];
>> }
>
> That's not a valid constexpr function.
Also, the right way to have used that macro would be:
#include <debug/debug.h>
// Element access.
reference
operator[](size_type __n)
{
__glibcxx_requires_subscript(__n);
return _M_instance[__n];
}
When not in debug mode that macro expands to nothing.
More information about the Libstdc++
mailing list