腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(8020)
视频
沙龙
1
回答
C++20:使用概念实现std::is_constructible
c++
、
c++20
、
typetraits
、
c++-concepts
<int, int>::value);
static_assert
(!
static_assert
(!
static_assert
(!);
static_assert
(!:value);
浏览 12
提问于2022-01-24
得票数 1
回答已采纳
1
回答
衰减到基类
c++
、
templates
、
c++17
、
typetraits
(std::is_same_v<base<DerivedDerived>::type,Derived>);
static_assert
(std::is_same_v<base<Base>::type,Base>);
static_assert
(std::is_same_v<base<0,Deriv
浏览 0
提问于2019-10-23
得票数 0
4
回答
请帮助我理解这个语法(在C++中实现静态断言)
c++
、
templates
、
syntax
、
metaprogramming
template <bool>struct
static_assert
<true> {}; // only true is defined#define
STATIC_ASSERT
(x)
static_assert
<(x)>()
STATIC_ASSERT
(true);
static_assert
<tru
浏览 4
提问于2010-06-23
得票数 7
回答已采纳
1
回答
static_assert
表达式不是__builtin_clz的积分常量表达式。
c++
、
clang
(leaing_ones(0b0000'0000) == 0);
static_assert
(leaing_ones(0b1100'0000) == 2);
static_assert
(leaing_ones(0b1111'0000) == 4);
static_a
浏览 0
提问于2021-06-04
得票数 0
回答已采纳
2
回答
如何使`
static_assert
`打印它在失败时得到的值?
c++
、
templates
、
c++14
、
c++17
、
static-assert
运行此命令: return PathLength;{
STATIC_ASSERT
(.)
static_assert
(__VA_ARGS__,#__VA_ARGS__) ^
浏览 7
提问于2019-12-24
得票数 2
回答已采纳
1
回答
奇怪的常量表达式类型错误
c++
、
c++11
、
language-lawyer
、
typeid
、
compiler-bug
""); // Fine
static_assert
(&typeid(A) != nullptr, ""); // Fine
static_assert
(&typeid(B) !
static_assert
(tA == tA, ""); // Fine (compar
浏览 6
提问于2016-09-21
得票数 3
2
回答
不可能的隐式移动操作?
c++
、
c++11
、
language-lawyer
、
move-semantics
、
compiler-bug
std::is_copy_constructible<X>::value, "");
static_assert
(!std::is_move_assignable<X>::value, "");
static_assert
(!(std::is_copy_constructible<A>::value, ""
浏览 3
提问于2017-01-30
得票数 3
回答已采纳
1
回答
如何在表达式编译错误时将概念求为假
c++
、
c++20
、
c++-concepts
、
static-assert
(outer<pass>);
static_assert
(not outer<bad_fail>);
static_assert
(not outer<fail>);这会导致一个令人困惑的错误:然后,我尝试将编译检查和
浏览 4
提问于2022-05-07
得票数 2
回答已采纳
2
回答
如何检索C99变量宏的最后一个参数?
c++
、
c
、
c99
、
c-preprocessor
Visual对失败的
static_assert
的错误消息完全由一个错误代码和
static_assert
的第二个参数组成,没有任何额外的消息表明它是静态断言失败。我想做一个宏来解决这个问题。例如,作为第一次尝试:您遇到的第一个问题是C预处理器不理解
STATIC_ASSERT
((std::is_same<T, U>::value)
浏览 6
提问于2014-06-03
得票数 6
回答已采纳
4
回答
如何使
static_assert
块在模板类中可重用?
c++
、
class
、
templates
、
c++17
、
static-assert
假设我有一个模板类,它生成多个static_asserts:class Foo
static_assert
(!std::is_const<T>::value,"");
static_assert
(!有办法使
static_assert
块可重用吗?一个"
static_ass
浏览 1
提问于2019-04-22
得票数 3
回答已采纳
2
回答
为什么is_invocable对引用参数的工作方式不同?
c++
type_traits> void foo_ref(int& i){}{
static_assert
(!
static_assert
(std::is_invocable<decltype(foo_cref), int>
浏览 0
提问于2020-11-17
得票数 2
回答已采纳
1
回答
为什么平凡的复制/移动可构造性取决于平凡的破坏性?
c++
、
c++11
、
trivially-copyable
(std::is_copy_constructible<Sample>::value, "");
static_assert
(std::is_trivially_copy_constructible<Sample>::value, ""); // Fails with GCC andClang
static_ass
浏览 1
提问于2020-09-16
得票数 8
1
回答
为什么对于引用而言,警察函数的行为是不同的?
c++
、
constexpr
(Args);{
static_assert
(count(ref) >= 0); // Error第一个
static_assert
工作得很好。第二个错误: <source>:12:19: error:
static_assert
expression
浏览 1
提问于2019-10-20
得票数 5
回答已采纳
1
回答
检测删除功能
c++
、
typetraits
、
deleted-functions
foo_is_deleted<>); // exist as not deleted
static_assert
( foo_is_deleted<float>); // foo(4.2f) selects foo(double)which is deleted.
static_assert
浏览 4
提问于2022-11-25
得票数 6
1
回答
有没有可能为不应该编译的表达式表达
static_assert
?
c++
、
c++11
、
static-assert
我想用下面的形式来表达一个
static_assert
:
static_assert
(expression should not compile); 让我添加一个完整的示例: template <boolBig>struct A<true> void a() {}or
static_assert
(!compile(A
浏览 19
提问于2019-03-17
得票数 10
回答已采纳
2
回答
gcc/clangvs.msvc:函数中的
static_assert
是否必须在返回类型不好时进行评估?
c++11
、
gcc
、
visual-c++
、
clang
、
language-lawyer
在这个简化的示例中,计算
static_assert
所需的编译器是auto foo(T t) -> void} {} {} gcc和clan
浏览 0
提问于2016-05-16
得票数 0
回答已采纳
1
回答
访问结构或联合中的填充是否安全?
c
、
struct
、
padding
static_assert
(_Alignof(char) < _Alignof(double), "Flip!"); char c[1];}; char c[1];};
static_assert
(sizeof(u
浏览 3
提问于2017-12-24
得票数 4
1
回答
在嵌套类型名称上生成模板的通用方法
c++
、
templates
、
c++17
D1<A>, type_x_id>>);
static_assert
D2<A>, type_x_id>>);/
浏览 4
提问于2022-07-13
得票数 2
回答已采纳
1
回答
C++概念允许我的类在声明/定义时指定它满足某些概念吗?
c++
、
c++-concepts
、
c++20
目前我能想到的最好的方法是使用
static_assert
,但我更喜欢更好的方式。concept bool SizedContainer = requires (C c){ c.end();};
static_assert
(!SizedContainer<std::forward_list<int>>);
浏览 3
提问于2018-01-10
得票数 12
回答已采纳
2
回答
是否将
static_assert
编译为二进制文件?
c++
、
compilation
、
static-assert
我想在我的
static_assert
项目中使用C++11来做一些编译时检查。 据我理解,
static_assert
不会在运行时执行,对吗?如果是这样的话,当我通过执行有关编译的命令(如gcc ... )来编译我的项目时,编译器会将
static_assert
构建到二进制文件中,或者
static_assert
将被完全忽略,就像注释一样?
浏览 12
提问于2021-12-23
得票数 0
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
C++20:核心语言
【C+11札记】:type traits简介
改善C语言程序代码的125个建议,第109到125个建议!
C+11及以上新特性大揭秘:现代化编程语言的必备利器
C+17 标准正式发布:开发者可更简单地编写和维护代码
热门
标签
更多标签
云服务器
ICP备案
实时音视频
即时通信 IM
对象存储
活动推荐
运营活动
广告
关闭
领券