C++ type equality not recognized under SFINAE context - by Bronek

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 718729 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/15/2012 3:04:51 PM
Access Restriction Public

Description

Template like the following may fail (under SFINAE context, so it's quiet failure) when both parameters are same type, and type T is a pointer to template specialization

template <typename T, T> struct same_ { typedef void* type; };

Outside of SFINAE context, similar code works as intended.
Sign in to post a comment.
Posted by Bronek on 1/16/2012 at 2:30 PM
Actual workaround posted in "Workarounds" tab
Posted by Bronek on 1/16/2012 at 12:55 PM
Ooops, code posted at 16/01/2012 at 12:13 is not working workaround, it disables SFINAE.
Posted by Bronek on 1/16/2012 at 12:13 PM
Thank you - great to know this is fixed!

For those stuck with the current version, here is workaround:

template <typename A> struct testme{};

typedef char true_;
typedef int false_;
template <typename T, T> struct same_ { typedef void* type; };

template <typename A>
struct has_path_
{
typedef testme<int> A::*f;
static false_ select(...);
static true_ select(typename same_<f, &A::path>::type);
};

template <typename A>
struct has_path
{
enum { value = sizeof(has_path_<A>::select(0)) == sizeof(true_) };
};

struct get
{
testme<int> path;
};

int main()
{
int t[(int)has_path<get>::value];
(void)t;
}
Posted by Microsoft on 1/16/2012 at 12:05 PM
Hi:
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by MS-Moderator07 [Feedback Moderator] on 1/15/2012 at 7:12 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 1/15/2012 at 3:41 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)