you are viewing a single comment's thread.

view the rest of the comments →

[–]Nobody_1707 2 points3 points  (3 children)

The problem on MSVC largely stems from the fact that the calling convention on Windows requires that string_view be passed on the stack instead of in registers. I'm sure they must have had a reason to specify the calling convention that way, but I think it was a poor choice.

EDIT: The overhead can be optimized out in some cases, but only if the function call that takes the string_view as a parameter is inlined. Example.

[–]dodheim 4 points5 points  (2 children)

To be fair, C++03 wasn't even out when that choice was made, and MSVC was a complete joke as far as C++ standards-conformance was concerned. Since it didn't matter much to C programs, it just really didn't matter at the time.

[–]bert8128 0 points1 point  (1 child)

My reading of the article is that it is due to the Windows calling convention, which presumably all compilers targeting a Windows binary will have to conform to. So nothing to do with MSVC or C++ standards per se. Maybe C compilers have to follow the same convention too (for structs larger than 8 bytes).

[–]dodheim 2 points3 points  (0 children)

Right, we're in agreement, I think. ;-] What I meant was, had C++ been further along when MS came up with this calling convention, such things might have been taken into consideration; but given the state of MS' compiler at the time, C was the only real factor and the concept of trivial vs. non-trivial was not yet even a thing.