COMP: making it compile on VS2017#2759
COMP: making it compile on VS2017#2759dzenanz wants to merge 1 commit intoInsightSoftwareConsortium:masterfrom
Conversation
The regression was introduced by 4f30980.
|
@dzenanz FYI, I did an similar partial revert for VS2107 on elastix! SuperElastix/elastix@fd523e5 Specifically to work around VS2107 compiler bug "Compile error when using "using declaration" referencing a base class type that refers to itself", EssentiaX - Reported March 12, 2019 [Fixed in version 16.2], https://developercommunity.visualstudio.com/t/486683 The compile error only seemed to appear when the type that the class was "using" was actually a base class. |
|
I saw SuperElastix/elastix@fd523e5. I tried that first, but then realized that |
| using PixelType = typename Superclass::PixelType; \ | ||
| using CellType = typename Superclass::CellType; \ | ||
| using CellAutoPointer = typename Superclass::CellAutoPointer; \ | ||
| using CellConstAutoPointer = typename Superclass::CellConstAutoPointer; \ | ||
| using CellRawPointer = typename Superclass::CellRawPointer; \ | ||
| using CellConstRawPointer = typename Superclass::CellConstRawPointer; \ | ||
| using CellTraits = typename Superclass::CellTraits; \ | ||
| using CoordRepType = typename Superclass::CoordRepType; \ | ||
| using InterpolationWeightType = typename Superclass::InterpolationWeightType; \ | ||
| using PointIdentifier = typename Superclass::PointIdentifier; \ | ||
| using PointIdIterator = typename Superclass::PointIdIterator; \ | ||
| using PointIdConstIterator = typename Superclass::PointIdConstIterator; \ | ||
| using CellIdentifier = typename Superclass::CellIdentifier; \ | ||
| using CellFeatureIdentifier = typename Superclass::CellFeatureIdentifier; \ |
There was a problem hiding this comment.
Are you sure all of these changes are necessary, for VS2017? I had the impression that the VS2017 error "C2886: symbol cannot be used in a member using-declaration" only occurred when the "type to be used" itself is a base-class of the class that has the using-declaration. (Compiler bug https://developercommunity.visualstudio.com/t/486683)
There was a problem hiding this comment.
You are more than welcome to take over this PR, and explore the minimum amount of changes which get it compile on VS2017.
There was a problem hiding this comment.
I'm having a look now, and it appears that there's another category of erroneous (!) VS2017 compile errors that we're encountering now after pull request #2567, saying:
error C2244: unable to match function definition to an existing declaration
This VS2017 compile error may be reproduced by:
template <typename T>
class Base
{
public:
using NestedType = T;
};
template <typename T>
class Derived : public Base<T>
{
using Superclass = Base<T>;
using typename Superclass::NestedType;
NestedType MemberFunction();
};
template <typename T>
typename Derived<T>::NestedType
Derived<T>::MemberFunction()
{ // <== error C2244: unable to match function definition to an existing declaration
return NestedType{};
}
And this particular error may be solved by a trailing return type instead:
template <typename T>
auto
Derived<T>::MemberFunction() -> NestedType
{ // OK!
return NestedType{};
}
And in this particular case (having a nested dependent type as return type), I think it would actually be quite nice to use a trailing return type.
To be continued...
Indeed, VS2017 supports both C++11 |
Partially reverted pull request InsightSoftwareConsortium#2567 commit 4f30980 "STYLE: Avoid repeating parent aliases" because of Visual Studio 2017 compile errors reported by Dženan Zukić at InsightSoftwareConsortium#2759 "COMP: making it compile on VS2017" Worked around the following VS2017 compile errors: > error C2653: '...': is not a class or namespace name > error C2886: '...': symbol cannot be used in a member using-declaration The compiler bug that caused these errors is reported here: "Compile error when using "using declaration" referencing a base class type that refers to itself" EssentiaX - Reported March 12, 2019 [Fixed in version 16.2] https://developercommunity.visualstudio.com/t/486683
|
Closing in favor of #2780. |
Partially reverted pull request #2567 commit 4f30980 "STYLE: Avoid repeating parent aliases" because of Visual Studio 2017 compile errors reported by Dženan Zukić at #2759 "COMP: making it compile on VS2017" Worked around the following VS2017 compile errors: > error C2653: '...': is not a class or namespace name > error C2886: '...': symbol cannot be used in a member using-declaration The compiler bug that caused these errors is reported here: "Compile error when using "using declaration" referencing a base class type that refers to itself" EssentiaX - Reported March 12, 2019 [Fixed in version 16.2] https://developercommunity.visualstudio.com/t/486683
Partially reverted pull request InsightSoftwareConsortium#2567 commit 77006be "STYLE: Avoid repeating parent aliases" because of Visual Studio 2017 compile errors reported by Dženan Zukić at InsightSoftwareConsortium#2759 "COMP: making it compile on VS2017" Worked around the following VS2017 compile errors: > error C2653: '...': is not a class or namespace name > error C2886: '...': symbol cannot be used in a member using-declaration The compiler bug that caused these errors is reported here: "Compile error when using "using declaration" referencing a base class type that refers to itself" EssentiaX - Reported March 12, 2019 [Fixed in version 16.2] https://developercommunity.visualstudio.com/t/486683
The regression was introduced by 4f30980.
WIP. Reduces number of compile failures on Visual Studio 2017 on My computer. I plan to get back to this later this week.