c++arraysstdarrayoutofrangeexception

What is __N() in this statement std::__throw_out_of_range(__N("array::at"))?


I was looking at the definition of at() function from array header file to clear some doubts. Here's the definition-

reference                   //typedef for &value_type of array
at(size_type __n)           //size_type is typedef for size_t
{
    if (__n >= _Nm)        //_Nm is typedef for size of array
        std::__throw_out_of_range(__N("array::at"));   //what is __N(...) ?
    return _M_instance[__n];        //_M_instance[...] is variable of type std::array
}

So, what is that N(...) on the last third line? Or more specifically, what does it do?


Solution

  • From their source code

    // This marks string literals in header files to be extracted for eventual
    // translation.  It is primarily used for messages in thrown exceptions; see
    // src/functexcept.cc.  We use __N because the more traditional _N is used
    // for something else under certain OSes (see BADNAMES).
    #define __N(msgid)     (msgid)