小编bog*_*ose的帖子

C++ 20 bit_cast vs reinterpret_cast

根据ISO C++ Commitee的最后一次会议,将在C++ 20标准中引入bit-cast.

我知道reinterpret_cast由于类型合规规则不适合这项工作,但我的问题是为什么他们选择不延伸reinterpret_cast处理对象,比如它的位序列表示,并且更倾向于将此功能作为一种新的语言结构?

c++ language-lawyer type-alias c++20

14
推荐指数
1
解决办法
1735
查看次数

将 std::web_view 工具引入标准有什么好处?

根据图书馆进化孵化器的最新会议,获得大力支持的设施之一是std::web_view

该提案在P1108R2 中描述,将用于

通过利用现有的网络标准和技术,实现现代、自然、多模式的用户交互。

std::web_view w("web_view test app");
  w.set_uri_scheme_handler("wv", [&](const std::string &uri, std::ostream &os) {
    std::cout << "request: " << uri << "\n";
    os << "<html><head><title>" << uri << "</title></head><body><p>" << uri << "</p><table>";
    for (auto &a : args)
      os << "<tr><td>" << a << "</td></tr>" << "\n"; // we need some kind of "to_html" utility function.
    os << "</table>";
    os << "<p><a href=\"" << uri << "/more.html" << "\">more</a></p>";
    os << "<ul id='dl'></ul>";
    os << …
Run Code Online (Sandbox Code Playgroud)

c++ c++20

5
推荐指数
1
解决办法
448
查看次数

三点运算符“...”用于初始化数组

考虑以下使用默认值初始化数组的示例:

static unsigned int array[10] = { [ 0 ... 9 ] = 5 };
Run Code Online (Sandbox Code Playgroud)

这个运算符到底是做什么的?

它与可变参数宏有关__VA_ARGS__

c operators variadic-macros

1
推荐指数
1
解决办法
1118
查看次数