Merge branch 'typedvariant-fix'

This commit is contained in:
Luke Street 2020-04-19 19:32:35 -04:00
commit c0688de578
1 changed files with 9 additions and 9 deletions

View File

@ -114,13 +114,13 @@ private:
public: public:
template<typename... _Args> template<typename... _Args>
static constexpr _TypedVariant Build(EnumType tp, _Args&&... args) { static constexpr _TypedVariant Build(EnumType tp, _Args&&... args) {
return _TypedVariant::_Builder<_Types...>::template _BuildSkip<_Args...>(tp, std::forward<_Args>(args)...); return _Builder<_Types...>::template _BuildSkip<_Args...>(tp, std::forward<_Args>(args)...);
} }
template<typename _Return, typename _Visitor> template<typename _Return, typename _Visitor>
constexpr auto visit(_Visitor&& visitor, _Return&& def) { constexpr auto visit(_Visitor&& visitor, _Return&& def) {
return std::visit([&](auto& arg) { return std::visit([&]<typename T0>(T0& arg) {
using T = std::decay_t<decltype(arg)>; using T = std::decay_t<T0>;
if constexpr (!T::is_monostate()) if constexpr (!T::is_monostate())
return visitor(arg); return visitor(arg);
return def; return def;
@ -129,8 +129,8 @@ public:
template<typename _Visitor> template<typename _Visitor>
constexpr void visit(_Visitor&& visitor) { constexpr void visit(_Visitor&& visitor) {
std::visit([&](auto& arg) { std::visit([&]<typename T0>(T0& arg) {
using T = std::decay_t<decltype(arg)>; using T = std::decay_t<T0>;
if constexpr (!T::is_monostate()) if constexpr (!T::is_monostate())
visitor(arg); visitor(arg);
}, static_cast<base&>(*this)); }, static_cast<base&>(*this));
@ -138,8 +138,8 @@ public:
template<typename _Return, typename _Visitor> template<typename _Return, typename _Visitor>
constexpr auto visit(_Visitor&& visitor, _Return&& def) const { constexpr auto visit(_Visitor&& visitor, _Return&& def) const {
return std::visit([&](const auto& arg) { return std::visit([&]<typename T0>(const T0& arg) {
using T = std::decay_t<decltype(arg)>; using T = std::decay_t<T0>;
if constexpr (!T::is_monostate()) if constexpr (!T::is_monostate())
return visitor(arg); return visitor(arg);
return def; return def;
@ -148,8 +148,8 @@ public:
template<typename _Visitor> template<typename _Visitor>
constexpr void visit(_Visitor&& visitor) const { constexpr void visit(_Visitor&& visitor) const {
std::visit([&](const auto& arg) { std::visit([&]<typename T0>(const T0& arg) {
using T = std::decay_t<decltype(arg)>; using T = std::decay_t<T0>;
if constexpr (!T::is_monostate()) if constexpr (!T::is_monostate())
visitor(arg); visitor(arg);
}, static_cast<const base&>(*this)); }, static_cast<const base&>(*this));