Consider the following code snippet:
struct Foo {}; template<typename ForwardIterator> struct Foo* Bar(ForwardIterator first, ForwardIterator last) { (void)first; (void)last; Foo *foo(nullptr); return foo; }
The above code snippet compiles in Clangv3.5 and GCCv4 0.9 .
However, it does not compile in VC ++ 2013.
Removing the struct identifier (see below) from the return type solves the problem:
struct Foo {}; template<typename ForwardIterator> Foo* Bar(ForwardIterator first, ForwardIterator last) { (void)first; (void)last; Foo *foo(nullptr); return foo; }
Q1:
Is this a visual studio bug?
Q2:
This problem arose because there is a .hc file in my Foo struct .hc (i.e. is a C struct ) and to use C / POD struct in my code, I use the identifier struct . Is this a bad idea (i.e., in C ++ code, should I avoid using the struct identifier this way)?
c ++ struct c ++ 11 visual-studio-2013 c ++ 14
101010
source share