7

I was looking through clang's C++ standard library, and found this class in the shared_ptr class.

class shared_ptr
// ...
private:
    struct __nat {int __for_bool_;};
// ...
};

I understand that this class is used to detect whether type conversion is possible at compile time, but its member __for_bool_ is never used anywhere in the class or the weak_ptr counterpart. So, my question is, what is the point of __for_bool_? Why not simply use an empty class for the same purpose?

I'm sure the standard library authors definitely know better than me.

Benjamin Buch
  • 4,752
  • 7
  • 28
  • 51
hohohmm
  • 197
  • 1
  • 12
  • Can you link the file and indicate the lines of code where the struct is declared? It would help to understand better the context where it is used. – LoS Sep 02 '23 at 19:59

0 Answers0