2

So the question is, does the latest standard specify when a function in the standard C++ library is declared inline or not?

Looking at the algorithm header file from the Clang, GCC and MSVC implementations, every single function, except for the ones which are constexpr, are declared inline.

I was gonna go on and ask about when to inline and what not, but I don't wanna have the usual argument about how the compiler knows better or micro optimizations, so I probably shouldn't even let this sentence stay in the question. Oh wait...

DeiDei
  • 10,205
  • 6
  • 55
  • 80
  • 6
    Even if the finished specification costs money, the [drafts are available](https://isocpp.org/std/the-standard) so you can check yourself. The last draft before ratification is usually the same as the finished standards text (the only difference being some blurb that's not important). – Some programmer dude Jan 01 '16 at 20:00
  • 6
    `inline` is about the ODR, not about inlining calls. And, no, it doesn't; it's up to the implementation. – Alan Stokes Jan 01 '16 at 20:01
  • `` is part of the implementation, and doesn't necessarily follow strict C++ rules anyway. The most important rule which is almost always violated is the use of `_[A-Z]` prefixes - you can't, an implementation must. – MSalters Jan 01 '16 at 21:12

1 Answers1

9

No. The implementation author chooses.

[C++14: 17.6.5.4/1]: It is unspecified whether any global or non-member functions in the C++ standard library are defined as inline (7.1.2).

[C++14: 17.6.5.5/1]: It is unspecified whether any member functions in the C++ standard library are defined as inline (7.1.2).

And recall that this has nothing to do with actual inlining nowadays; it really only affects the ODR.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055