libstdc++: Prevent specialization of std::indirect and std::polymorphic
std::indirect and std::polymorphic are marked to disallow user specialization, following C++ standard proposals.
This commit prevents users from specializing the std::indirect and std::polymorphic templates in libstdc++. These templates, introduced based on C++ standard proposals P3019R14, already have inherent restrictions that preclude user specialization. By marking them with _GLIBCXX_NO_SPECIALIZATIONS, the compiler enforces these restrictions, enhancing type safety and preventing potential misuse.
In Details
The C++ standard library components std::indirect and std::polymorphic, introduced by P3019R14, are designed with intrinsic limitations preventing their specialization by users. This commit formally enforces these restrictions within libstdc++ by adding the _GLIBCXX_NO_SPECIALIZATIONS attribute to their declarations in include/bits/indirect.h. This ensures that attempts to specialize these templates at compile time will result in an error, aligning the implementation with the intended usage and adhering to the guidelines from the C++ standardization committee.
- std::indirect
- A C++ standard library template, likely related to memory or type manipulation, introduced in a recent standard revision (P3019R14). It's designed to provide access to underlying types or values in a controlled manner.
- std::polymorphic
- A C++ standard library template, likely related to polymorphism or type erasure. It's designed to facilitate object-oriented patterns, possibly enabling operations on objects of different types through a common interface.
- template specialization
- In C++, a mechanism to provide a custom implementation of a function template or a class template for a specific set of template arguments. User-defined specializations are generally allowed for library components unless explicitly prohibited.
- _GLIBCXX_NO_SPECIALIZATIONS
- A compiler or library-specific macro used in libstdc++ to indicate that a particular template should not be specialized by the user. Compiling code that attempts to specialize such a template will typically result in a compile-time error.
- P3019R14
- A C++ standard proposal document that introduced certain library features, including
std::indirectandstd::polymorphic.