x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
cast.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\cast.hpp
旋转
特效
属性
历史版本
// boost cast.hpp header file ----------------------------------------------// // (C) Copyright Kevlin Henney and Dave Abrahams 1999. // Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/conversion for Documentation. // Revision History // 23 JUn 05 numeric_cast removed and redirected to the new verion (Fernando Cacciola) // 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included //
instead (the workaround did not // actually compile when BOOST_NO_LIMITS was defined in // any case, so we loose nothing). (John Maddock) // 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never // worked with stock GCC; trying to get it to do that broke // vc-stlport. // 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp. // Removed unused BOOST_EXPLICIT_TARGET macro. Moved // boost::detail::type to boost/type.hpp. Made it compile with // stock gcc again (Dave Abrahams) // 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal // Review (Beman Dawes) // 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams) // 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC // (Dave Abrahams) // 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) // 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) // 27 Jun 00 More MSVC6 workarounds // 15 Jun 00 Add workarounds for MSVC6 // 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) // 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) // 29 Dec 99 Change using declarations so usages in other namespaces work // correctly (Dave Abrahams) // 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors // as suggested Darin Adler and improved by Valentin Bonnard. // 2 Sep 99 Remove controversial asserts, simplify, rename. // 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, // place in nested namespace. // 3 Aug 99 Initial version #ifndef BOOST_CAST_HPP #define BOOST_CAST_HPP # include
# include
# include
# include
# include
# include
// It has been demonstrated numerous times that MSVC 6.0 fails silently at link // time if you use a template function which has template parameters that don't // appear in the function's argument list. // // TODO: Add this to config.hpp? # if defined(BOOST_MSVC) && BOOST_MSVC < 1300 # define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type
* = 0 # else # define BOOST_EXPLICIT_DEFAULT_TARGET # endif namespace boost { // See the documentation for descriptions of how to choose between // static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<> // polymorphic_cast --------------------------------------------------------// // Runtime checked polymorphic downcasts and crosscasts. // Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup, // section 15.8 exercise 1, page 425. template
inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) { Target tmp = dynamic_cast
(x); if ( tmp == 0 ) throw std::bad_cast(); return tmp; } // polymorphic_downcast ----------------------------------------------------// // BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited. // WARNING: Because this cast uses BOOST_ASSERT(), it violates // the One Definition Rule if used in multiple translation units // where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER // NDEBUG are defined inconsistently. // Contributed by Dave Abrahams template
inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) { BOOST_ASSERT( dynamic_cast
(x) == x ); // detect logic error return static_cast
(x); } # undef BOOST_EXPLICIT_DEFAULT_TARGET } // namespace boost # include
#endif // BOOST_CAST_HPP
cast.hpp
网页地址
文件地址
上一页
12/113
下一页
下载
( 4 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.