qt-maybe
qt-maybe copied to clipboard
Cannot have protected QObject member of type Maybe<bool>
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)
^~~~~~
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.
Hmm, but I was just trying to use Maybe -- does it generate an Either with both branches of same type by accident?
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.