http://llvm.org/bugs/show_bug.cgi?id=22605
Bug ID: 22605
Summary: Move template parameter defaults to forward
declarations
Product: libc++
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
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> >
class _LIBCPP_TYPE_VIS_ONLY list
: 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> >
class _LIBCPP_TYPE_VIS_ONLY list;
template <class _Tp, class _Alloc /* = allocator<_Tp>*/ >
class _LIBCPP_TYPE_VIS_ONLY list
: 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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs