language-lawyer

    3热度

    1回答

    我问这是因为,尽管事实上称号Table 11是简单类型说明符,它们指定的类型,语法生产simple-type-specifier没有提及这种类型的组合,作为简单类型说明符。那么unsigned int是一个简单类型说明符? 编辑: 我不认为给予 aforementioned question的答案是正确的。如果这是真的,一个不能够说,声明 void* operator new(std::size_

    1热度

    1回答

    我有以下结构类型: typedef struct PG_Point PG_Point; struct PG_Point { int x; int y; }; typedef struct PG_Size PG_Size; struct PG_Size { int width; int height; }; typedef struct P

    2热度

    1回答

    看看下面的例子,我创建一个std::mutex,将其锁定,然后用手将锁定到另一个线程: #include <future> #include <mutex> int main() { // Create and lock a mutex std::mutex mutex; std::unique_lock<decltype(mutex)> lock(mutex

    34热度

    1回答

    一个我已经幸运地遇到是constexpr counter,又名状态元编程。正如在帖子中提到的,它似乎在C++ 14下是合法的,我想知道C++ 17有什么变化吗? 以下是主要立足岗位 template <int N> struct flag { friend constexpr int adl_flag(flag<N>); constexpr operator int() {

    1热度

    1回答

    有一天,我需要(不可否认,第一次)获取堆栈跟踪为一个字符串。 e.printStackTrace()当然不会返回一个。 我需要使用this答案中的解决方案来获得我想要的。 是的我意识到你可以得到堆栈跟踪元素,然后自己遍历它们,并且有第三方库可以在一行中完成它,但是为什么标准库中没有这样做会为你做并返回一个字符串?

    2热度

    3回答

    https://kukuruku.co/post/i-do-not-know-c/ 问题#7:小端系统上的两个不同的编译器 #include <stdio.h> void f(int *i, long *l) { printf("1. v=%ld\n", *l); /* (1) */ *i = 11; /* (2) */ printf("2. v=%ld\

    57热度

    4回答

    我不小心写了一些这样的代码: foo = [42] k = {'c': 'd'} for k['z'] in foo: # Huh?? print k 然而令我惊讶,这不是一个语法错误。相反,它打印{'c': 'd', 'z': 42}。 我猜测是代码被翻译字面上是这样的: i = iter(foo) while True: try: k['z'] =

    8热度

    2回答

    考虑following code: #include <type_traits> template<template<class...> class T, class... U> struct is_specialization_of : std::false_type{}; template<template<class...> class T, class... U> struct

    3热度

    2回答

    所以这是一个非常基本的问题和超级微不足道的,但我只是通过编程原则&实践在c + +和我的程序阅读一个字符串和一个int是行为不同于Bjarne Stroustrup写的书,所以id很惊讶如果他犯了一个错误。反正这里的代码: #include "..\std_lib_facilities.h" int main() { cout << "Please enter your first

    8热度

    1回答

    我用3个编译器测试了以下代码,得到3个不同的结果:错误,警告和正常。 GCC(5.3):错误:警告:nullptr恒定的为 '布尔' 的隐式转换从 '的std :: nullptr_t' 到 'const的东西&' 锵(3.8)无效用户定义的转换 MSVC(14.1):没有错误,没有警告 哪个编译器是正确的?我知道这是一个指针类型和bool之间的微不足道的转换。但是关于std::nullptr_t