C++ 虐我千百遍
109 subscribers
31 photos
7 links
Download Telegram
想要一个功能:#define 里面能根据参数字符串的开头,dispatch 到不同的 #define 里面
今天遇到的神奇问题:gcc 13.2 的 barrier 头文件有个地方写了 unqualified move(没加 std::),导致我 CE 了😁😭
今日学习
今日也是希望 gcc 赶快有 deducing this 的一天,原因是写了:
Num operator+(const Num& rhs) const & { ... }
Num operator+(const Num& rhs) && { ... }
Num operator+(Num&& rhs) const & { ... }
Num operator+(Num&& rhs) && { ... }
C++ 虐我千百遍 pinned «招管理员 投稿请在讨论群 #投稿»
今日不会 GCC Precompiled Headers:
在文件夹 headers 仅存放 stdio.h.gch,然后 -I headers 编译如下程序

#include <stdio.h>
#include <cstdio>

就会报 fatal error: headers/stdio.h: No such file or directory
解决方法是复制一份 stdio.h 到 headers 文件夹

by @wys_1
啥时候能把 vector<char> 直接变成 vector<int> 啊,现在得另外构造一个然后 memcpy(
gcc-13 还没有 inout_ptr,要到 14 才有,没敢用,糊了一个上去,还好这东西还是在大概能糊的范围内的
今日感觉 C++ 缺一个 std::unlock_guard(
今日感觉 C++ 缺一个给 structured binding 加 concept constraint 的功能(如果不符合限制就 ill formed)
草,std::optional 的移动构造并不能把参数设成 nullopt,坑了我半天
今日狗屁代码:为了绕开制杖 std::vector<bool>,开了一个 std::vector<std::array<bool, 1>>
今日我傻逼:
局部作用域的 lock 和外面的另一个 lock 重名了,导致锁错东西了,产生各种神奇的结果……
从下午调到现在!!!
Forwarded from Lancern's Treasure Chest
Forwarded from Lancern's Treasure Chest
有没有那种 std::copy,但是 move assignment(
草,原来就叫 std::move
建议加入 std::copy 的 cppreference 底下的 see also
template<typename T>
decltype(auto) avg(T x, T y)
noexcept(noexcept((x + y) / 2))
requires requires { (x + y) / 2; }
{
return (x + y) / 2;
}