[LLVMbugs] [Bug 22605] New: Move template parameter defaults to forward declarations

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 16 11:32:48 PST 2015


            Bug ID: 22605
           Summary: Move template parameter defaults to forward
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eniebler at boost.org
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

There are lots of places in libc++ where a class template is forward declared
without defaults for template parameters, only to have the defaults specified
later on the definition. An example is in <list> which first has this:

template <class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS_ONLY list;

to be followed later with this:

template <class _Tp, class _Alloc = allocator<_Tp> >
    : private __list_imp<_Tp, _Alloc>

This actually makes a difference to clang when std::list is passed as a
template template parameter. See <http://llvm.org/bugs/show_bug.cgi?id=22601>,
which was discovered when porting real-world code from libstdc++ to libc++.

If the default parameter is moved to the forward declaration, the problem goes
away. In other words, this is preferred:

template <class _Tp, class _Alloc = allocator<_Tp> >

template <class _Tp, class _Alloc /* = allocator<_Tp>*/ >
    : private __list_imp<_Tp, _Alloc>

In my own code, I achieve this with one internal header with nothing but
forward declarations. All defaults are specified there. All other headers
include this header first.

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/20150216/aebb42fa/attachment.html>

More information about the llvm-bugs mailing list