Re: some bugs in VS2010 RC
Mycroft Holmes wrote:
(1) if a class has swap(T&) and swap(T&&) then in some cases we cannot
take a pointer to swap(T&).
the following sample shows that in ordinary code, the pointer can be
taken, but in a template it can't.
if you remove AAA::swap(AAA&&) it works.
template <typename T>
void fff(T& x, void (T::*)(T&))
{
}
template <typename T>
void fff(T& x)
{
fff(x, &T::swap);
}
I think the compiler has difficulties with combining overload resolution =
and template parameter deduction. It does look like a bug to me, I think =
the code should work as written. As a workaround, try these:
fff<T>(x, &T::swap);
// or
void (T::*F)(T&) = &T::swap;
fff(x, F);
// or
fff(x, static_cast<void (T::*)(T&)>(&T::swap));
(2) sometimes the compiler is unable to fill-it default template
parameters, and it emits...well... bizarre error messages.
in the sample below, if you write "BBB<this_t, roll_t, LENGTH>" it
works, if you write "BBB<this_t, roll_t>" it does not compile.
template <typename r1_t, typename r2_t, int LENGTH1 = r1_t::length,
int LENGTH2 = r2_t::length>
class BBB;
template <typename r1_t, typename r2_t, int LENGTH>
class BBB<r1_t, r2_t, LENGTH, 1>
{
typedef BBB<r1_t, r2_t, LENGTH, 1> this_t;
public:
BBB(int = 0)
{
}
static const int length = LENGTH;
// bug: VS2010 RC will complain if LENGTH is omitted...
// it says that 'length' is undefined
template <typename roll_t>
inline BBB<this_t, roll_t, LENGTH> operator<<(roll_t) const
{
return 0;
}
};
Yes, looks like a bug, too. Comeau accepts this.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not =
necessarily a good idea. It is hard to be sure where they are going to =
land, and it could be dangerous sitting under them as they fly overhead. =
-- RFC 1925