|
Boost : |
Subject: Re: [boost] [utility/result_of] decltype-based implementation breaking valid code on msvc-10
From: Eric Niebler (eric_at_[hidden])
Date: 2010-04-06 11:59:41
On 4/6/2010 12:52 AM, Daniel James wrote:
> I'll revert it for now but we
> should probably change config to define BOOST_NO_DECLTYPE for Visual
> C++ 10 if it's buggy on that compiler.
I had a similar thought. Here is the bug I filed against msvc:
https://connect.microsoft.com/VisualStudio/feedback/details/548883
And for easy reference, here is the code:
template<class T>
struct S;
template<class X, class Y> struct pair {};
template<class T>
S<T> wrap(T) { return 0; }
template<class T>
struct S
{
S(int = 0) {}
// The following use of decltype causes the compiler to blow up:
decltype(wrap(pair<T,T>())) foo() { return wrap(pair<T,T>()); }
// The following, which should be equivalent, compiles without
// problem:
//S<pair<T,T> > foo() { return wrap(pair<T,T>()); }
};
int main()
{
S<int> s;
}
As you can see, decltype forces the types used in the expression to be
complete. I'm not sure if that's conforming, but I hope not. I'd say
it's premature to turn decltype on across the board for this compiler
until we have a better idea of its limitations. The safe thing to do for
1.43 is to turn it off. We can always turn it on for 1.44.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk