Is there a difference in compile time duration, when I intensively use similarly instantiated result_type_t's defined as follows:
-
First form:
template< typename F, typename ...Args > using result_type_t = decltype(std::declval< F >()(std::declval< Args >()...)); -
Second form:
template< typename F, typename ...Args > struct result_type { using type = decltype(std::declval< F >()(std::declval< Args >()...)); }; template< typename F, typename ...Args > using result_type_t = typename result_type< F, Args... >::type;
?
What I mean is using the same instantiation of result_type_t< F, Args... > repeatedly for the same F, Args... template arguments in diverse places of the same translation unit. For the type alias case there no new type-id introduced and, on my mind, compiler will deduce decltype() every time again and again when encounters it. For the second version there is corresponding type-id result_type< F, Args... > saved somewhere in "symbol table" for a current translation unit after its first instantiation and its member typedef type already ready to use when needed (i.e. "precalculated"). Am I right?
Aucun commentaire:
Enregistrer un commentaire