Skip to content

Commit

Permalink
move bad_variant_access back to <variant>
Browse files Browse the repository at this point in the history
  • Loading branch information
achabense committed Aug 17, 2023
1 parent b4aecea commit 12bfbb7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
21 changes: 0 additions & 21 deletions stl/inc/exception
Original file line number Diff line number Diff line change
Expand Up @@ -396,27 +396,6 @@ _EXPORT_STD template <class _Ty>
void rethrow_if_nested(const _Ty&) = delete; // requires /GR option
#endif // ^^^ !defined(_CPPRTTI) ^^^

_EXPORT_STD class bad_variant_access
: public exception { // exception for visit of a valueless variant or get<I> on a variant with index() != I
public:
bad_variant_access() noexcept = default;

_NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override {
return "bad variant access";
}

#if !_HAS_EXCEPTIONS
protected:
void _Doraise() const override { // perform class-specific exception handling
_RAISE(*this);
}
#endif // ^^^ !_HAS_EXCEPTIONS ^^^
};

[[noreturn]] inline void _Throw_bad_variant_access() {
_THROW(bad_variant_access{});
}

_STD_END

#pragma pop_macro("new")
Expand Down
21 changes: 21 additions & 0 deletions stl/inc/variant
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,27 @@ private:
}
};

_EXPORT_STD class bad_variant_access
: public exception { // exception for visit of a valueless variant or get<I> on a variant with index() != I
public:
bad_variant_access() noexcept = default;

_NODISCARD const char* __CLR_OR_THIS_CALL what() const noexcept override {
return "bad variant access";
}

#if !_HAS_EXCEPTIONS
protected:
void _Doraise() const override { // perform class-specific exception handling
_RAISE(*this);
}
#endif // ^^^ !_HAS_EXCEPTIONS ^^^
};

[[noreturn]] inline void _Throw_bad_variant_access() {
_THROW(bad_variant_access{});
}

_EXPORT_STD template <class _Ty, class... _Types>
_NODISCARD constexpr bool holds_alternative(const variant<_Types...>& _Var) noexcept {
// true iff _Var holds alternative _Ty
Expand Down

0 comments on commit 12bfbb7

Please sign in to comment.