Skip to content

Inheriting constructors of isl::optional<T> results in a compilation error on gcc 6.4 and lower #55

@improbablejan

Description

@improbablejan

The following code fails to compile on gcc versions 6.4 and lower:

struct foo : nonstd::optional<int> {
    using nonstd::optional<int>::optional;
};

while it appears to work with gcc version 7.1 and above. The compilation error produced (with --std=c++14 GCC 6.4 on godbolt.org):

<source>:1704:34: error: 'template<class U> constexpr foo::foo(U&&)' inherited from 'nonstd::optional_lite::optional<int>'

     using nonstd::optional<int>::optional;

                                  ^~~~~~~~

<source>:1704:34: error: conflicts with version inherited from 'nonstd::optional_lite::optional<int>'

<source>:1704:34: error: 'template<class U> foo::foo(nonstd::optional_lite::optional<T>&&)' inherited from 'nonstd::optional_lite::optional<int>'

<source>:1704:34: error: conflicts with version inherited from 'nonstd::optional_lite::optional<int>'

<source>:1704:34: error: 'template<class U> foo::foo(const nonstd::optional_lite::optional<T>&)' inherited from 'nonstd::optional_lite::optional<int>'

<source>:1704:34: error: conflicts with version inherited from 'nonstd::optional_lite::optional<int>'

Compiler returned: 1

@improbable-nickkrempel believes it could be due to the change in inheriting constructor semantics
which resolves issue 1941. Switching the SFINAE method used from a default argument to a default template type does seem to resolve the issue. Is there any reason why optional_REQUIRES_A is used when using SFINAE with constructors instead of optional_REQUIRES_T, or could the method be switched in order to better support older GCC versions?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions