Better understanding the STL

Apr 20, 2016 at 9:57pm
Alright, so this is a topic where I have very little exposure. So I feel like I need some sort of guidance to understand it all.

This has happened to me more than once. I will sometimes follow the breakpoints in visual studio which eventually lead me to STL code. For example, this is code from Math.h

1
2
3
_Check_return_ _ACRTIMP short __cdecl _dclass(_In_ double _X);
_Check_return_ _ACRTIMP short __cdecl _ldclass(_In_ long double _X);
_Check_return_ _ACRTIMP short __cdecl _fdclass(_In_ float _X);


I don't know what it does, but the part that bothers me most is how unusual the syntax is.

For example, what does "_In_" do and why do they care to surround every input parameter with it? I never do that with my code.

Moreover, what are these functions even returning? I see like 3 or 4 variables or keywords that I've never seen before: "_Check_return_, _ACRTIMP, __cdecl"? Plus, why is the short there?
Apr 20, 2016 at 10:11pm
I never do that with my code.

And you shouldn't. In C++, anything that has two underscores in a row (__cdecl) and anything tha tbegins with an underscore followed by a capital (_Check_return_, _ACRTIMP, _In_) are symbols reserved for use by the internals of the standard library, for their internal purposes. (see http://en.cppreference.com/w/cpp/language/identifiers#In_declarations )

Here you see a few different internal Microsoft-only things

_Check_return_ and _In_ are part of The Microsoft source-code annotation language.

_Check_return_ is documented here: https://msdn.microsoft.com/en-us/library/jj159529.aspx

_In_ is documented here https://msdn.microsoft.com/en-us/library/hh916382.aspx

__cdecl is the venerable old Microsoft keyword for the C calling convention, documented here: https://msdn.microsoft.com/en-us/library/zkwh89ks.aspx

_ACRTIMP is a macro, your compiler should tell you what it is

Plus, why is the short there?

it's the return type of the three functions being declared
Last edited on Apr 20, 2016 at 10:14pm
Apr 20, 2016 at 10:25pm
At this stage, I suspect you won't get much understanding of the STL by trying to figure out how other people have implemented it.

Start with learning how to use the basic containers; what they're for, what you can do with them. Start with vector.
Topic archived. No new replies allowed.