Skip to content

boost::get overloads for boost::spirit::x3::variant should at least lack BOOST_NOEXCEPT #753

Description

@blashyrkh-ravendark

Since boost::get may throw boost::bad_get (in the event of a failed application on the given arg), all boost::get overloads for refs or ptrs to boost::spirit::x3::variant objects in boost/spirit/home/x3/support/ast/variant.hpp should at least lack BOOST_NOEXCEPT (which leads to std::terminate invocation when a function indeed throws).

Example:

#include <boost/spirit/home/x3/support/ast/variant.hpp>
#include <iostream>

namespace x3 = boost::spirit::x3;

int main()
{
    x3::variant<bool, int> variant {5}; // Program crash
    // boost::variant<bool, int> variant {5}; // No issue

    try {
        const auto v = boost::get<bool>(variant);
    } catch(const boost::bad_get& e) {
        std::cerr << "boost bad_get: " << e.what() << std::endl;
        return 1;
    } catch(const std::exception& e) {
        std::cerr << "std exception: " << e.what() << std::endl;
        return 1;
    } catch(...) {
        std::cerr << "Unknown error";
        return 1;
    }

    return 0;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions