martinmoene / variant-lite

variant lite - A C++17-like variant, a type-safe union for C++98, C++11 and later in a single-file header-only library
Boost Software License 1.0
239 stars 25 forks source link

Names clash between variant-lite and expected-lite #16

Closed flexferrum closed 6 years ago

flexferrum commented 6 years ago

I included both nonstd/expected.hpp and nonstd/variant.hpp in one file and got the following error:

/projects/flexferrum-Jinja2Cpp/thirdparty/nonstd/expected-light/include/nonstd/expected.hpp:531:8: error: redefinition of ‘struct nonstd::in_place_t’
 struct in_place_t{};
        ^
/projects/flexferrum-Jinja2Cpp/thirdparty/nonstd/variant-light/include/nonstd/variant.hpp:272:8: error: previous definition of ‘struct nonstd::in_place_t’
 struct in_place_t {};
        ^
flexferrum commented 6 years ago

UPD: If include 'expected.hpp' before 'variant.hpp' and set 'nonstd_lite_HAVE_IN_PLACE_TYPES' macro manually, errors will become more serous:

In file included from /projects/flexferrum-Jinja2Cpp/src/internal_value.h:9:0,
                 from /projects/flexferrum-Jinja2Cpp/src/expression_evaluator.h:4,
                 from /projects/flexferrum-Jinja2Cpp/src/filters.h:4,
                 from /projects/flexferrum-Jinja2Cpp/src/filters.cpp:1:
/projects/flexferrum-Jinja2Cpp/thirdparty/nonstd/variant-light/include/nonstd/variant.hpp:1035:53: error: expected ‘)’ before ‘,’ token
     explicit variant( nonstd_lite_in_place_type_t(T), Args&&... args)
                                                     ^
/projects/flexferrum-Jinja2Cpp/thirdparty/nonstd/variant-light/include/nonstd/variant.hpp:1043:53: error: expected ‘)’ before ‘,’ token
     explicit variant( nonstd_lite_in_place_type_t(T), std::initializer_list<U> il, Args&&... args )
                                                     ^
/projects/flexferrum-Jinja2Cpp/thirdparty/nonstd/variant-light/include/nonstd/variant.hpp:1051:52: error: ‘I’ is not a type
     explicit variant( nonstd_lite_in_place_index_t(I), Args&&... args )
                                                    ^
/projects/flexferrum-Jinja2Cpp/thirdparty/nonstd/variant-light/include/nonstd/variant.hpp:1051:54: error: expected ‘)’ before ‘,’ token
     explicit variant( nonstd_lite_in_place_index_t(I), Args&&... args )
                                                      ^
/projects/flexferrum-Jinja2Cpp/thirdparty/nonstd/variant-light/include/nonstd/variant.hpp:1059:52: error: ‘I’ is not a type
     explicit variant( nonstd_lite_in_place_index_t(I), std::initializer_list<U> il, Args&&... args )
flexferrum commented 6 years ago

I'm considering the following way of fix: move common types, macros etc. to separate repo and then combine the 'production' headers via Jinja2 - just include one Jinja2 template into another. It allows to keep the common code consistent.

martinmoene commented 6 years ago

This is a 'duplicate' of issue 14 at expected-lite .

I'd like to keep the shared "in_place infrastructure" as simple as it is now and refrain from file generation for any-lite, optional-lite and expected-lite.

I've had a go at using optional-lite's (etc.) in_place setup before, but was not immediately successful (can't remember why). Also I can't remember from the top of my head why expected-lite's in_place is as it is. Further, I have a longstanding action to update expected-lite (old repo) (new repo) to the latest proposal, a moving target.

References:

martinmoene commented 6 years ago

Done per nonstd-lite issue 17.

flexferrum commented 6 years ago

I'll try to check it out tonight. Thanks!

flexferrum commented 6 years ago

It works!

martinmoene commented 6 years ago

Nice! Thanks for letting me know.