Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用BOOST_THROW_EXCEPTION宏?参数是什么?我不知道,我似乎找不到任何可读的例子。
BOOST_THROW_EXCEPTION
您只需将异常对象传递给它:
BOOST_THROW_EXCEPTION(std::range_error("Index out of range"));
它将包装异常以使其从类派生boost::exception(如果它还不是它的子类),并添加诸如源文件和行之类的信息。
boost::exception
Boost.Exception FAQ对优势和使用示例有很好的见解。