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 26 forks source link

Improve visitor #9

Closed martinmoene closed 6 years ago

martinmoene commented 6 years ago

From PR #8, @flexferrum

Only one thing here stuns me here: I see no way to implement std-conformance visitor for C++98/03. I mean explicit specification of visitor's return type for C++98/03 case. And I still can't decide what to do with it.

variant visit, cppreference:

template <class Visitor, class... Variants>
constexpr /*see below*/ visit(Visitor&& vis, Variants&&... vars);
flexferrum commented 6 years ago

I've got some thoughts, related to code generation. And here is one significant problem: there is (or I see?) no way to make uniform visit signature for C++98/03 and C++11 etc. In the first case you have to explicitly declare visitor return type. In the second case you can (somehow) calculate it from the visitor.

martinmoene commented 6 years ago

Above bullets should have conveyed the message a split between C++98 and C++11 is perhaps to be made.

That may not solve your acute problem, but would be merely the result of the attention being drawn to visit.

flexferrum commented 6 years ago

I suppose I know how to implement all this stuff.

martinmoene commented 6 years ago

Show it off ;)

Still a week to come near a usable computer. Working from phone right now enabling merging good pull requests (GPRS ;)

flexferrum commented 6 years ago

Show it off ;)

No problem. :) That's the prototype of implementation. It's needed to be checked, generalized and so on. But before I need the review regarding to coding style, naming etc. you take care of. Also I'm considering about perfect forwarding here and more test cases.

https://github.com/flexferrum/variant-lite/commit/e877e597616e4cdd1b49a732400010a37938ab68

martinmoene commented 6 years ago

Implemented per PR #11, continued in issue #12