Long compile times due mangling of return types in function templates

Jonathan Wakely jwakely.gcc@gmail.com
Sun Apr 26 13:25:00 GMT 2015


On 26 April 2015 at 11:05, Avi Kivity wrote:
> @@ -526,12 +527,14 @@ public:
>      }
>       template <typename Func>
> -    futurize_t<std::result_of_t<Func(T&&...)>> then(Func&& func) noexcept {
> +    auto // futurize_t<std::result_of_t<Func(T&&...)>>
> +    then(Func&& func) noexcept {
>          return

This changes the meaning of the code. For the original the function
will not participate in overload resolution when
result_of_t<Func(T&&...)> is not a valid type. You have changed that
so the function can be called with invalid types and might be chosen
by overload resolution, resulting in a compiler error.

So feel free to do that in your own code if you want to avoid the
compile-time overhead of SFINAE, but there are very good reasons it
shouldn't be done in general.



More information about the Gcc-help mailing list