[PATCH 2/2] libstdc++: use new built-in trait __add_const

Marc Glisse marc.glisse@inria.fr
Tue Mar 21 11:20:42 GMT 2023


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


More information about the Libstdc++ mailing list