`
zhangyafei_kimi
  • 浏览: 261660 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

boost.BOOST_STATIC_ASSERT源码整理和使用说明

 
阅读更多

Source

#include <boost/config.hpp>

#include <boost/detail/workaround.hpp>

//

namespace kimi_boost

{

//这个模板类只有声明,没有定义

//注意:这里没有{}

//所以如果定义这个类型的对象将会失败

template <bool> struct STATIC_ASSERTION_FAILURE2;

//一个true类型的完全特化,并且带定义

template <> struct STATIC_ASSERTION_FAILURE2<true>{};

template<int x> struct static_assert_test2{};

#ifdef BOOST_STATIC_ASSERT

#undef BOOST_STATIC_ASSERT

#define BOOST_STATIC_ASSERT(B) typedef static_assert_test2< sizeof(STATIC_ASSERTION_FAILURE2< (bool)( B ) >) > nothing##__COUNTER__

#endif //BOOST_STATIC_ASSERT

}

Test code

void static_assert_test()

{

using namespace kimi_boost;

BOOST_STATIC_ASSERT(1);

BOOST_STATIC_ASSERT(1 == 1);

BOOST_STATIC_ASSERT(true);

BOOST_STATIC_ASSERT(0); //compile error

STATIC_ASSERTION_FAILURE2<true> asd;

STATIC_ASSERTION_FAILURE2<false> asd2;

}

Output

Compile time error

分享到:
评论

相关推荐

    test-assert.rar_games_test assert

    This is hairier than you d think, involving games with stdio and signals.

    人体姿态估计的强大算法

    parse_matlab\util\assert.m parse_matlab\util\printSkel.m parse_matlab\util\sampleWithR.m parse_matlab\util\isum.m parse_matlab\util\buildHistExps.m parse_matlab\util\local_sum_zero.m parse_...

    GENESIS 2000 DFM PE

    The DFM Programming Environment is one of the many unique concepts of the Genesis 2000 system. Unlike any existing tool, the DFM Programming Environment (DFMPE) enables any user with elementary ...

    0.gray_python.cn_灰帽子_中文版.pdf

    0.gray_python.cn_灰帽子_中文版.pdf

    Boost学习笔记

    Boost是C++标准库开发人员参与编写的,非常好。里面有各种数组、线程池、通信库等,是Linux、Window通用的东西。不学他,就落伍了。

    ZendFramework中文文档

    2.3.2. 使用声明(Assert)来编写条件性的 ACL 规则 3. Zend_Auth 3.1. 简介 3.1.1. 适配器 3.1.2. 结果 3.1.3. 身份的持久(Persistence) 3.1.3.1. 在PHP Session 中的缺省持久(Persistence) 3.1.3.2. 实现...

    一、机器学习概览

    assert sklearn.__version__ &gt;= "0.20" sklearn.__version__ 1 获取数据并整理 1.1 下载数据 创建datasets/lifesat目录 爬取oecd_bli_2015.csv&gdp_per_capita.csv数据到该目录下 import os datapath = os.path....

    downloads.part1.rar

    boost-1.70.0.tar.gz boostorg-any-boost-1.70.0.tar.gz boostorg-array-boost-1.70.0.tar.gz boostorg-asio-boost-1.70.0.tar.gz boostorg-assert-boost-1.70.0.tar.gz boostorg-assign-boost-1.70.0.tar.gz ...

    downloads.part3.rar

    boost-1.70.0.tar.gz boostorg-any-boost-1.70.0.tar.gz boostorg-array-boost-1.70.0.tar.gz boostorg-asio-boost-1.70.0.tar.gz boostorg-assert-boost-1.70.0.tar.gz boostorg-assign-boost-1.70.0.tar.gz ...

    基于gym的pytorch深度强化学习实现源码+项目说明(PPO,DQN,SAC,DDPG,TD3等算法).zip

    1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,...

    node-nanomsg.zip

    var assert = require('assert'); var AF_SP = nanomsg.AF_SP; var NN_PAIR = nanomsg.NN_PAIR; var msg = new Buffer('hello'); var recv = new Buffer(msg.length); var s1, s2, ret; s1 = nanomsg.nn_socket(AF_...

    downloads.part2.rar

    boost-1.70.0.tar.gz boostorg-any-boost-1.70.0.tar.gz boostorg-array-boost-1.70.0.tar.gz boostorg-asio-boost-1.70.0.tar.gz boostorg-assert-boost-1.70.0.tar.gz boostorg-assign-boost-1.70.0.tar.gz ...

    simple_peripheral_cc2640r2lp_app.rar_APP5000.CC_HAL_蓝牙对手机

    蓝牙对手机通讯。 318/5000 这是引发的断言的Application的回调处理程序 *在堆栈中。 在堆栈中定义EXT_HAL_ASSERT时 *项目将在引发断言时调用此函数, *并可用于观察或捕获预期的违规行为 *行为。

    boost 1.41 中文文档,使用帮助,教程手册

    fatalerror99 array, bind & mem_fn, dynamic_bitset, function, functional/hash, in_place_factory & typed_in_place_factory, lambda, ref, smart_ptr, static_assert, string_algo, type_traits, typeof ...

    vehicle-speed-check-master.zip

    assert type(self.angle_unit) == int, "bin_size should be divisible by 360" def extract(self): height, width = self.img.shape gradient_magnitude, gradient_angle = self.global_gradient() gradient_...

    贪吃蛇代码

    assert Window_Width % Cell_Size == 0, "Window width must be a multiple of cell size." # Ensuring that only whole integer number of cells fit perfectly in the window. assert Window_Height % Cell_Size...

    luassert:Lua的断言库

    assert. True ( true ) assert. is . True ( true ) assert. is_true ( true ) assert. is_not . True ( false ) assert. is . Not . True ( false ) assert. is_not_true ( false ) assert. are . equal ( 1 , 1 ) ...

    junit的jar包

    junit.framework.Assert.class junit.framework.AssertionFailedError.class junit.framework.ComparisonCompactor.class junit.framework.ComparisonFailure.class junit.framework.JUnit4TestAdapter.class junit....

    C#例子代码 A0002_Assert

    C#例子代码 A0002_AssertC#例子代码 A0002_AssertC#例子代码 A0002_AssertC#例子代码 A0002_AssertC#例子代码 A0002_AssertC#例子代码 A0002_AssertC#例子代码 A0002_AssertC#例子代码 A0002_AssertC#例子代码 A0002...

    基于gym的pytorch深度强化学习实现源码+项目说(PPO,DQN,SAC,DDPG,TD3算法.zip

    基于gym的pytorch深度强化学习实现源码+项目说明(PPO,DQN,SAC,DDPG,TD3等算法).zip 本人学习强化学习(PPO,DQN,SAC,DDPG等算法),在gym环境下写的代码集。 主要研究了PPO和DQN类算法,根据各个论文复现了如下改进: ...

Global site tag (gtag.js) - Google Analytics