[llvm-bugs] [Bug 27798] New: declval() can be implemented without requiring a template instantiation.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 17 17:00:35 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27798

            Bug ID: 27798
           Summary: declval() can be implemented without requiring a
                    template instantiation.
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eniebler at boost.org
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

declval gets used *everywhere*. It doesn't need to instantiate a template.
Rather than:

  template <class _Tp>
  typename add_rvalue_reference<_Tp>::type
  declval() noexcept;

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));

In a large code base that makes heavy use of templates, this small change is a
measured  2% compile-time win.

I think the as-if rule gives implementers enough latitude to make this change.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160518/a42b1518/attachment.html>


More information about the llvm-bugs mailing list