1//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
2
3//Distributed under the Boost Software License, Version 1.0. (See accompanying
4//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#include <boost/config.hpp>
7
8#if defined( BOOST_NO_EXCEPTIONS )
9# error This program requires exception handling.
10#endif
11
12#include <boost/exception/get_error_info.hpp>
13#include <boost/exception/info.hpp>
14#include <boost/detail/lightweight_test.hpp>
15#include <boost/detail/workaround.hpp>
16#include <errno.h>
17
18typedef boost::error_info<struct tag_errno,int> info_errno;
19
20class
21my_exception:
22 public boost::exception
23 {
24 };
25
26int
27main()
28 {
29 try
30 {
31 errno=1;
32 throw my_exception() << info_errno(errno);
33 }
34 catch(
35 my_exception & x )
36 {
37 BOOST_TEST(1==*boost::get_error_info<info_errno>(x));
38 }
39 return boost::report_errors();
40 }
41

source code of boost/libs/exception/test/errno_test.cpp