C++ Logo

std-discussion

Advanced search

[temp.spec.general] ¶6 - "The usual access checking rules do not apply ..."

From: David Bakin <david_at_[hidden]>
Date: Wed, 9 Dec 2020 18:33:17 -0800
I just learned about this exception to the access rules (there are several
posts on SO about it, plus there's an originating GotW article about it
<http://www.gotw.ca/gotw/076.htm> quite awhile ago).

So you can use this to legally access protected and private members of a
class, if you're willing to suffer Mr Sutter's disparagement of your
gentlemanliness.

My question is: why? What is - or are - the motivating use case(s) for
this loophole? I assume it has something to do with implementing standard
library features? But what?

(I understand now that it's been extended to explicit specialization as
well as explicit instantiation - that's apparently from
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0692r1.html (but
correct me please if I'm wrong). But surely that wouldn't have been
suggested had this feature not long been part of the language.)

-- David Bakin

Received on 2020-12-09 20:33:32