This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

232. "depends" poorly defined in

Section: [reserved.names] Status: CD1 Submitter: Peter Dimov Opened: 2000-04-18 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [reserved.names].

View all issues with CD1 status.

Discussion: uses the term "depends" to limit the set of allowed specializations of standard templates to those that "depend on a user-defined name of external linkage."

This term, however, is not adequately defined, making it possible to construct a specialization that is, I believe, technically legal according to, but that specializes a standard template for a built-in type such as 'int'.

The following code demonstrates the problem:

#include <algorithm>
template<class T> struct X
 typedef T type;
namespace std
 template<> void swap(::X<int>::type& i, ::X<int>::type& j);

Proposed resolution:

Change "user-defined name" to "user-defined type".


This terminology is used in section 2.5.2 and 4.1.1 of The C++ Programming Language. It disallows the example in the issue, since the underlying type itself is not user-defined. The only possible problem I can see is for non-type templates, but there's no possible way for a user to come up with a specialization for bitset, for example, that might not have already been specialized by the implementor?

[Toronto: this may be related to issue 120.]

[post-Toronto: Judy provided the above proposed resolution and rationale.]