This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Should _GLIBCXX_DEBUG affect tr1/array?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]