https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71187
Bug ID: 71187 Summary: declval() can be implemented without requiring a template instantiation Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: eric.niebler at gmail dot com Target Milestone: --- declval gets used *everywhere*. It doesn't need to instantiate a template. Rather than: template<typename _Tp> inline typename add_rvalue_reference<_Tp>::type declval() noexcept { static_assert(__declval_protector<_Tp>::__stop, "declval() must not be used!"); return __declval_protector<_Tp>::__delegate(); } declval can be defined as: template<typename _Tp, typename _Up = _Tp&&> _Up __declval(int); template<typename _Tp> _Tp __declval(long); template<typename _Tp> auto declval() noexcept -> decltype(__declval<_Tp>(0)) { static_assert(__declval_protector<_Tp>::__stop, "declval() must not be used!"); return __declval_protector<_Tp>::__delegate(); } In a large code base that makes heavy use of templates, this small change is a measured 4% compile-time win (g++ (GCC) 5.x 20160302). I think the as-if rule gives implementers enough latitude to make this change.