Closed Kaosumaru closed 7 years ago
Hi, thanks for the bug report. I've committed a fix to master, would you mind giving it a try and seeing whether it's solved the issue for you?
I'm going to go ahead and close this now, please let me know if you're still having problems.
With the current revision the guard in variant.hpp is not protecting all duplicate definitions. If variant.hpp is included after optional.hpp I get the following errors with clang 3.9.0:
In file included from test.cpp:38:
./cpp17_headers/include/stx/variant.hpp:102:27: error: redefinition of 'in_place_type_t'
template <class T> struct in_place_type_t {
^
./cpp17_headers/include/stx/optional.hpp:288:27: note: previous definition is here
template <class T> struct in_place_type_t {
^
In file included from test.cpp:38:
./cpp17_headers/include/stx/variant.hpp:106:30: error: redefinition of 'in_place_type'
constexpr in_place_type_t<T> in_place_type{};
^
./cpp17_headers/include/stx/optional.hpp:300:30: note: previous definition is here
constexpr in_place_type_t<T> in_place_type{};
^
In file included from test.cpp:38:
./cpp17_headers/include/stx/variant.hpp:108:28: error: redefinition of 'in_place_index_t'
template <size_t I> struct in_place_index_t {
^
./cpp17_headers/include/stx/optional.hpp:293:28: note: previous definition is here
template <size_t I> struct in_place_index_t {
^
In file included from test.cpp:38:
./cpp17_headers/include/stx/variant.hpp:112:31: error: redefinition of 'in_place_index'
constexpr in_place_index_t<I> in_place_index{};
^
./cpp17_headers/include/stx/optional.hpp:302:31: note: previous definition is here
constexpr in_place_index_t<I> in_place_index{};
Everything works fine when variant.hpp is included first.
The errors above are with '#define STX_NO_STD_OPTIONAL' and '#define STX_NO_STD_VARIANT'. When your header picks up clangs 'experimental/optional' there are different conflicts with 'in_place_t' and 'in_place' no matter the order of the includes.
Both headers declare std::in_place_t.