On Tue, 21 Mar 2023, Ken Matsui via Libstdc++ wrote:
/// add_const +#if __has_builtin(__add_const) + template<typename _Tp> + struct add_const + { using type = __add_const(_Tp); }; +#else template<typename _Tp> struct add_const { using type = _Tp const; }; +#endif
Is that really better? You asked elsewhere if you should measure for each patch, and I think that at least for such a trivial case, you need to demonstrate that there is a point. The drawbacks are obvious: more code in libstdc++, non-standard, and more builtins in the compiler.
Using builtins makes more sense for complicated traits where you can save several instantiations. Now that you have done a couple simple cases to see how it works, I think you should concentrate on the more complicated cases.
-- Marc Glisse