The following code compiles with GCC 4.7 and clang 3.0, but not with MSVC 10:
template <typename X>
struct point
{
template <typename Seq>
struct point_iterator
{
template <typename T>
struct deref;
template <typename Sq>
struct deref<point_iterator<Sq> >
{
};
};
};
int main()
{
typedef point<int> point_t;
typedef point_t::point_iterator<point_t> Iterator;
Iterator::deref<Iterator> m;
}
The compiler error that MSVC gives is:
test.cpp
testcpp(21) : error C2079: 'm' uses undefined struct 'point<X>::point_iterator<Seq>::deref<T>'
with
[
X=int,
Seq=point_t
]
and
[
T=Iterator
]
I think the type in question should be defined, since it should match the partial specialization of deref.
- Is this valid code? If so, and rejecting it is a bug on MSVC’s part, does anyone know whether the bug has already been reported?
- If it’s a bug, does anyone know of a workaround for it?
The problem is that MSVC10 does not agree that you specialized the class. If you try this
You’ll find that
Iterator::deref<Iterator>::specialexists with gcc, but with MS onlybasicexists.I do think your code is correct.
It’s seems that only partial specialization is affected. Specializing on
intworks as expected.