-
-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] replace mbgl::variant with std::variant #991
[WIP] replace mbgl::variant with std::variant #991
Conversation
@@ -407,12 +407,12 @@ Ignores parseExpressionIgnores() { | |||
std::optional<TestData> parseTestData(const filesystem::path& path) { | |||
TestData data; | |||
auto maybeJson = readJson(path.string()); | |||
if (!maybeJson.is<JSDocument>()) { // NOLINT | |||
if (!std::holds_alternative<JSDocument>(maybeJson)) { // NOLINT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what was linted here, if someone could help me with that one I'd happily check and maybe remove the NOLINT comment
I'll do some searching in the meanting to try to figure out what analyzer I should run to test this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try removing it? If the CI passes we can remove it.
I think Mapbox used some kind of linter in the past, but we are not (yet).
036031d
to
282c86f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall but I would like to know why the Overload
helper is needed.
include/mbgl/util/overloaded.hpp
Outdated
namespace util | ||
{ | ||
|
||
template <typename... Ts> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything in include
will become part of our public API. Is this intended? Can you add some triple slash comments to indicate what this template struct is for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may make sense to make it internal, in that case you can move it to /src
.
Some comments (and a link to cppreference) would still be a good idea in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed! I believe there's not need for it to be public but I have to check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, I moved it to src/mbgl/util
the API for the API is as follows: which means we've got to pass 1 visitor for N (which could also be 0) variants in order to obtain the same behavior as one way to do so is to manually create a visitor with multiple overloads for operator()(...) e.g.: it effectively inherits from a bunch of lambdas (so it has all their operator()(...)) in a single place (it, unfortunately, also needs a deduction guide for c++17 to allow for {..} initialization from the lambdas) maybe I made the explanation way too long sorry for that! here's where I took it from, by the way: https://en.cppreference.com/w/cpp/utility/variant/visit |
aac58c8
to
bf34bd5
Compare
Please click re-request review when you are ready! Thanks 🙂 |
b15e082
to
6f10640
Compare
6f10640
to
7b047e4
Compare
rename `Overload` to `Overloaded`
7b047e4
to
7a70a97
Compare
Hi! I've been working on this on and off but have struggled with a couple things in the public headers (notably changes involving some stuff that mbgl::variant and std::variant handle differently - mostly related to operator== and co.). In any case since this has been a long PR and has been lingering I've had to rebase several times. I believe the changes that exist now (that don't touch public headers) could be merged in a first step. Then we can move to the other (fewer) changes to the public headers and a couple platform things. Those will, hopefully, be faster to do than this one. I'd rather have everything done in one PR but I've not had the time to figure out what happens to a couple headers when I changed to std::variant (the compiler cries for help with errors). Keeping this up to date will become increasingly harder if it lingers and I'd rather at least make a small step. What do you think? |
0f7c1ab
to
89832ab
Compare
I also have 0 idea what this wants from me: `/platform/macos/src/MLNMapViewDelegate.h:88:63: error: expected a type
If someone could help me with iOS that would be amazing! |
@bencsikandrei Sorry for never replying, I am afraid I don't understand that error either. Let's see if we can get this in a mergable state. |
Closing because stale, I have opened #2946 |
This is part 1/n of a series of commits (or PRs?) towards solving: #893
My idea for this PR is to not aim at fully resolving this issue, as I believe it would be too much for one PR, but rather make small increments towards that goal (solve the simple things first, etc...)
My decision was to split into at a couple commits since I have some concerns regarding replacing some of the functionality of mbgl::variant with std::variant equivalents (.match and some of its operator== semantics come to mind)
Please let me know if my decision suits what you have envisioned for this task
Thanks!