Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6374575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:30:18+00:00 2026-05-25T01:30:18+00:00

I freak out whenever I open up any STL-related code from Visual Studio’s implementation

  • 0

I freak out whenever I open up any STL-related code from Visual Studio’s implementation while debugging my code:

// From <xtree>

if (_Where == begin())
    {   // insert at beginning if before first element
    if (_DEBUG_LT_PRED(this->comp,
        this->_Kfn(_Val), _Key(_Where._Mynode())))
        return (_Insert(true, _Where._Mynode(), _Val));
    }
else if (_Where == end())
    {   // insert at end if after last element
    if (_DEBUG_LT_PRED(this->comp,
        _Key(_Rmost()), this->_Kfn(_Val)))
        return (_Insert(false, _Rmost(), _Val));
    }
//...
else if (_DEBUG_LT_PRED(this->comp,
    _Key(_Where._Mynode()), this->_Kfn(_Val))
    && (++(_Next = _Where) == end()
        || _DEBUG_LT_PRED(this->comp,
            this->_Kfn(_Val), _Key(_Next._Mynode()))))
    {   // insert after _Where
    if (_Isnil(_Right(_Where._Mynode())))
        return (_Insert(false, _Where._Mynode(), _Val));
    else
        return (_Insert(true, _Next._Mynode(), _Val));
    }

The presence of comments makes me feel as though a human wrote them, but the poor formatting, liberal use of underscores at the beginning of everything (why?), and extremely unreadable conditions like (++(_Next = _Where) == end()
|| _DEBUG_LT_PRED ...)
make me feel as though they were generated from another piece of source code, not written as-is.

Does anyone know which of those is the case? (If it was generated from some other piece of code, I’d be interested in knowing how/why this was done.)


For the record, here’s the same thing, but “properly formatted”:

if (Where == begin())
{
    // insert at beginning if before first element
    if (DEBUG_LT_PRED(this->comp, this->Kfn(Val), Key(Where.Mynode())))
        return (Insert(true, Where.Mynode(), Val));
}
else if (Where == end())
{
    // insert at end if after last element
    if (DEBUG_LT_PRED(this->comp, Key(Rmost()), this->Kfn(Val)))
        return (Insert(false, Rmost(), Val));
}
//...
else if (DEBUG_LT_PRED(this->comp, Key(Where.Mynode()), this->_Kfn(Val))
    && (++(Next = Where) == end()
        || DEBUG_LT_PRED(this->comp, this->_Kfn(Val), Key(Next.Mynode()))))
{
    // insert after Where
    if (Isnil(Right(Where.Mynode())))
        return (Insert(false, Where.Mynode(), Val));
    else
        return (Insert(true, Next.Mynode(), Val));
}

IMHO this is more like how it would turn out if a human wrote it, but then again, I have no idea.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:30:18+00:00Added an answer on May 25, 2026 at 1:30 am

    Two things:

    1. The indentation is actually fine, although nowadays unusual (and I personally hate it): they use an indentation of four, which is achieved via spaces, but use tabs for all multiples of eight. This used to be the standard almost everywhere (notably it’s still the default setting in several editors such as Vim). But as a consequence, the code is only indented correctly if you set your tab width to 8. So the code actually looks like this:

      else if (_Where == end())
          {   // insert at end if after last element
              if (_DEBUG_LT_PRED(this->comp,
                  _Key(_Rmost()), this->_Kfn(_Val)))
                  return (_Insert(false, _Rmost(), _Val));
          }
      

      Which, though still unusual, is perfectly logical and legible.

    2. It’s good style (or even mandated?) that the standard library uses only reserved identifiers to avoid name clashes with customers’ C++ code. These reserved names are either names starting with an underscore followed by a capital letter (_DEBUG_LT_PRED, _Key), or two underscores (not in this code, but the GCC libstdc++ is littered with __x etc.).

    Hence the alphabet soup.

    But yes, this code is indeed manually written – at least it is in the case of the GCC. The active source branch of the libstdc++ looks exactly like the code above, and isn’t auto-generated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: Answered on serverfault. Thanks! A product I'm testing appears to freak out when
Okay! I know some people are gonna freak out at me, but, I tried
I am using Visual Studio 2010, and I have a LINQ-to-SQL DBML file that
While reading a binary file using DJGPP on DOS this code hangs. This happens
Don't freak out about the length of my post, it's pretty simple, I just
I'm just about to freak out. I currently have to work on a website
UPDATE: OK I figured it out, looks like fread has a filesize limitation, changed
I'm using MiGLayout and being the freak i am, i was thinking if it's
Resharper (paired with StyleCop) has made me a bit of a neat freak when
I enjoy using recursion whenever I can, it seems like a much more natural

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.