Ticket #2821: test.cpp

File test.cpp, 752 bytes (added by paul.kolomiets@…, 14 years ago)

issue reproduce test

Line 
1#include <string>
2#include <iostream>
3
4#include <boost/exception.hpp>
5#include <boost/lexical_cast.hpp>
6
7typedef boost::error_info<struct os_error_info_tag, int> os_error_info_base;
8
9class os_error_info : public os_error_info_base
10{
11public:
12 os_error_info(int const& err_code)
13 : os_error_info_base(err_code) {}
14
15private:
16 std::string value_as_string() const
17 {return "Error code: " + boost::lexical_cast<std::string> (value());}
18};
19
20int main(int argc, char* argv[])
21{
22 try
23 {
24 throw boost::enable_error_info(std::exception("value_as_string test")) <<
25 os_error_info(10);
26 }
27 catch (boost::exception const& ex)
28 {
29 std::cerr << boost::diagnostic_information(ex) << std::endl;
30 }
31
32// std::cin.get();
33 return 0;
34}