boost:exception使用实例
/************************************************************************/
/*功能描述: boost exception使用实例 */
/*作者 : kernel_main */
/*创建时间: 2014.6.8 */
/************************************************************************/
#include <iostream>
#include <exception> #include <boost/exception/all.hpp> struct my_exception : /* 自定义异常类 */
virtual std::exception, /* 虚继承,struct默认public继承 */
virtual boost::exception /* 虚继承,struct默认public继承 */
{
/* 空实现,不需要实现代码 */
}; /* 异常信息的类型 */
typedef boost::error_info<struct tag_err_no, int> err_no;
typedef boost::error_info<struct tag_err_str,std::string> err_str; int main()
{
using namespace boost;
try
{
try
{
/* 抛出异常,存储错误码 */
throw my_exception() << err_no();
}
catch (my_exception& e) /* 捕获异常,使用引用形式 */
{
std::cout << *get_error_info<err_no>(e) << std::endl;
std::cout << e.what() << std::endl;
e << err_str("other info"); /* 向异常追加信息 */
throw; /* 再次抛出异常 */
}
}
catch (my_exception& e)
{
std::cout << *get_error_info<err_str>(e) << std::endl;
std::cout << e.what() << std::endl;
}
return ;
}
boost:exception使用实例的更多相关文章
- boost exception
boost exception provides a new exception type, that lets you add data to an exception after it has b ...
- boost::asio 使用实例
#include <iostream> #include <boost/asio.hpp> using namespace std; using namespace boost ...
- boost exception jam0.exe 异常错误
在Windows 8 64 bit下执行boost_1_53_0的bootstrap.bat出现了jam0.exe执行错误 搜索网页发现需要修改两处文件: tools/build/v2/engine/ ...
- boost:thread使用实例
/************************************************************************/ /*功能描述: boost thread使用实例 ...
- boost库之udp广播实例
//UdpLinkServer.h //udp服务 #pragma once #include <boost/asio/ip/tcp.hpp> #include <boost/asi ...
- Boost 1.61.0 Library Documentation
http://www.boost.org/doc/libs/1_61_0/ Boost 1.61.0 Library Documentation Accumulators Framework for ...
- boost开发指南
C++确实很复杂,神一样的0x不知道能否使C++变得纯粹和干爽? boost很复杂,感觉某些地方有过度设计和太过于就事论事的嫌疑,对实际开发工作的考虑太过于理想化.学习boost本身就是一个复杂度,有 ...
- Win7下Boost库的安装
Boost库是C++领域公认的经过千锤百炼的知名C++类库,涉及编程中的方方面面,简单记录一下使用时的安装过程 1.boost库的下载 boost库官网主页:www.boost.org 2.安装 将下 ...
- (八)boost库之异常处理
(八)boost库之异常处理 当你面对上千万行的项目时,当看到系统输出了异常信息时,你是否想过,如果它能将文件名.行号等信息输出,该多好啊,曾经为此绞尽脑汁. 今天使用boost库,将轻松的解决这个问 ...
随机推荐
- Codeforces Round #368 (Div. 2) D. Persistent Bookcase
Persistent Bookcase Problem Description: Recently in school Alina has learned what are the persisten ...
- NeHe OpenGL教程 第二十九课:Blt函数
转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...
- jq鼠标点击滚动锚点
鼠标点击滚动锚点 //滚动锚点 $('.menus-c ul li a').click(function(){ //alert(); $('html, body').animate({ scrollT ...
- grunt构建前端自动化的开发环境
废话不多说.直奔主题. 1.安装node. 别问为什么.如果你不知道,说了你还是不知道. 别问怎么安装,自己去百度. 2.安装grunt_CLI. 安装完node,并且安装成功了,后.下载grunt_ ...
- Inno Setup安装、卸载时判断是否程序正在运行
var ErrorCode: Integer; IsRunning: Integer; // 安装时判断客户端是否正在运行 function InitializeSetup(): Boolean; b ...
- Matlab学习:读取指定文件夹及其五级子文件夹内的文件
OpenCV2.4.X版本提供了三个函数来读取指定目录内的文件,它们分别是: (1)GetListFiles:读取指定目录内所有文件,不包含子目录: (2)GetListFilesR:读取指定目录及其 ...
- Sqlserver中存储过程,触发器,自定义函数(一)
Sqlserver中存储过程,触发器,自定义函数 1.存储过程有关内容存储过程的定义:存储过程的分类:存储过程的创建,修改,执行:存储过程中参数的传递,返回与接收:存储过程的返回值:存储过程使用游标. ...
- C# 自定义事件(EventArgs)
1,自定义事件: public class TextChangeEventArgs : EventArgs { private string message; public TextC ...
- hdu-Danganronpa(AC自动机)
Problem Description Danganronpa is a video game franchise created and developed by Spike Chunsoft, t ...
- ubuntu搭建分布式hadoop-2.6.0概略和错误
详细配置:http://blog.csdn.net/ggz631047367/article/details/42426391 1.修改机器/etc/hostname分别为 master s ...