Skip to content
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

Cannot have protected QObject member of type Maybe<bool> #3

Open
singpolyma opened this issue Sep 21, 2017 · 3 comments
Open

Cannot have protected QObject member of type Maybe<bool> #3

singpolyma opened this issue Sep 21, 2017 · 3 comments

Comments

@singpolyma
Copy link

Either.h: In instantiation of ‘class Either<bool, bool>’:
Maybe.h:80:18:   required from ‘class Maybe<bool>’
journalentry.h:62:14:   required from here
Either.h:98:3: error: ‘Either<T1, T2>::Either(const T2&) [with T1 = bool; T2 = bool]’ cannot be overloaded
   Either(const T2& t2)
   ^~~~~~
Either.h:93:3: error: with ‘Either<T1, T2>::Either(const T1&) [with T1 = bool; T2 = bool]’
   Either(const T1& t1)
   ^~~~~~
@robertknight
Copy link
Owner

Thank-you for the report.

A limitation of the current API design is that both types used in the variant have to be different. The error is that the compiler will not be able to decide which of the "left" or "right" values to set when constructing the variant from some value.

I'm not intending to make further changes to this as a variant class has been added to the C++ standard library for C++17 (std::variant) and you can find polyfills for compilers that don't ship with it yet.

@singpolyma
Copy link
Author

Hmm, but I was just trying to use Maybe -- does it generate an Either with both branches of same type by accident?

@robertknight
Copy link
Owner

Oh, good grief. You're right. Maybe<T> uses Either<bool, T> in its definition. The definition ought to be something like Either<NothingType, T> where "NothingType" is an internal type that is only used to represent a missing value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants