boost地址\u v4::from\u string()崩溃

boost地址\u v4::from\u string()崩溃,boost,crash,boost-asio,Boost,Crash,Boost Asio,当我传递空字符串或无效地址时,address_v4::from_string()崩溃 address_v4 address = address_v4::from_string(""); boost版本:1_53实际上不会崩溃。它只是抛出一个异常,如文档所示: #include <boost/asio.hpp> #include <iostream> int main() { try { auto address = boost::asio::ip::a

当我传递空字符串或无效地址时,address_v4::from_string()崩溃

address_v4 address = address_v4::from_string("");

boost版本:1_53实际上不会崩溃。它只是抛出一个异常,如文档所示:

#include <boost/asio.hpp>
#include <iostream>

int main() {
    try {
    auto address = boost::asio::ip::address_v4::from_string("");
    } catch(std::exception const& e) {
        std::cout << e.what() << "\n";
    }
}
#include <boost/asio.hpp>
#include <iostream>

int main() {
    boost::system::error_code ec;
    auto address = boost::asio::ip::address_v4::from_string("", ec);
    if (!ec)
        std::cout << "Address: " << address << '\n';
    else
        std::cout << "Error: " << ec.message();
}