YSTest: ios.hpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

ios.hpp
浏览该文件的文档.
1 /*
2 © 2015 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YB_INC_ystdex_ios_hpp_
29 #define YB_INC_ystdex_ios_hpp_ 1
30
31 #include "../ydef.h"
32 #include <ios> // for std::basic_ios, std::ios_base::iostate;
33
34 namespace ystdex
35 {
36
42 template<typename _tChar, class _tTraits>
43 void
44 setstate(std::basic_ios<_tChar, _tTraits>& ios, std::ios_base::iostate state) ynothrow
45 {
46 const auto except(ios.exceptions());
47
48 ios.exceptions(std::ios_base::goodbit);
49 ios.setstate(state);
50 ios.exceptions(except);
51 }
52
62 template<typename _tChar, class _tTraits>
63 void
64 rethrow_badstate(std::basic_ios<_tChar, _tTraits>& ios,
65 std::ios_base::iostate state = std::ios_base::badbit)
66 {
67 setstate(ios, state);
68 throw;
69 }
70
71 } // namespace ystdex;
72
73 #endif
74
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:766
ystdex
特性测试宏。
Definition: ydef.h:822
ystdex::rethrow_badstate
void rethrow_badstate(std::basic_ios< _tChar, _tTraits > &ios, std::ios_base::iostate state=std::ios_base::badbit)
设置流状态并重新抛出当前异常。
Definition: ios.hpp:64
ystdex::setstate
void setstate(std::basic_ios< _tChar, _tTraits > &ios, std::ios_base::iostate state)
设置流状态。
Definition: ios.hpp:44