c++11 相关问题

将此标记用于必须编译为C ++ 11的代码(不使用C ++ 14或更高版本中引入的任何功能)。

有没有办法从 C++ 正则表达式中提取搜索? (不是关于正则表达式的问题,而是#include <regex>)

给定一个 C++ std 正则表达式,有没有办法弄清楚该正则表达式会搜索什么?取出构建时放入的字符串? 我看过 https://en.cppreference.com/w/cpp/regex/

回答 1 投票 0

C++0x 和 C++11 有什么区别?

我在这里看到这两个术语的混合使用。 维基百科说 C++11,以前也称为 C++0x ... 但我不知道为什么。 为什么它首先被称为C++0x,然后是C++11? 另外,这是什么...

回答 4 投票 0

如何在模板类方法内迭代“T”类型的数组?

我是一名学生,正在学习 C++11,目前我正在尝试为我的课程项目实现我自己版本的 Vector 模板。 我在编写返回

回答 1 投票 0

将成员函数定义或绑定到“variable like”关键字。不带括号执行

有没有办法将成员函数绑定到成员变量之类的东西? 假设我有简单的向量结构: 结构体Vec3 { 整数x、y、z; Vec2 xy() const { 返回 Vec2(x, y); } 向量...

回答 2 投票 0

Future 不返回对 C++ 中值的引用

我刚刚开始学习 C++ 多线程并遵循这个优秀的教程。 但是,当我打印 Future 返回的字符串的内存地址时,我得到了不同的地址......

回答 1 投票 0

错误类别有静态地址吗?

如果我抛出一个system_error,error_category-object是否被复制或作为引用,以便以下代码中的两个地址始终相同? #包括 使用命名空间...

回答 1 投票 0

强制编译时 constexpr [重复]

在 C++11 中我们得到 constexpr: constexpr int foo (int x) { 返回x+1; } 是否可以使用动态值 x 来调用 foo 并引发编译时错误?也就是说,我想创建一个 foo...

回答 4 投票 0

可变模板无法编译

#包括 模板 结构体TransformFunc; 模板 类 TransformFunc #include <stdio.h> template <typename FuncType, FuncType> struct TransformFunc; template <typename Arg, typename... Args, void(*func)(Arg, Args...)> class TransformFunc<void(*)(Arg, Args...), func> { public: static void apply(Arg arg, Args... args) { func(arg, args...); } }; void test1(int x) { printf("test1: int%d\n", x); } void test2 (int x, float y) { printf("test2: int%d float%f\n", x, y); } int main(int, char **) { TransformFunc<decltype(&test1), &test1>::apply(5); TransformFunc<decltype(&test2), &test2>::apply(5, 1.23f); // Error here. return 0; } 1>------ Build started: Project: main, Configuration: Debug x64 ------ 1> main.cpp 1>main.cpp(33): error C2440: 'specialization' : cannot convert from 'void (__cdecl *)(int,float)' to 'void (__cdecl *)(int)' 1> This conversion requires a reinterpret_cast, a C-style cast or function-style cast 1> main.cpp(33) : see reference to class template instantiation 'TransformFunc<void (__cdecl *)(int,float),void test2(int,float)>' being compiled 1>main.cpp(33): error C2973: 'TransformFunc<void(__cdecl *)(Arg,Args...),func>' : invalid template argument 'void (__cdecl *)(int,float)' 1> main.cpp(9) : see declaration of 'TransformFunc<void(__cdecl *)(Arg,Args...),func>' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 我不明白为什么 test2 实例化无法编译。有什么想法吗? 我不明白为什么 test2 实例化无法编译 该程序格式良好,截至 2024 年 5 月已被所有 3 个主要编译器接受。 演示。

回答 1 投票 0

为什么C++11允许GC? [已关闭]

SO是一场狗屎秀。感谢您的搭车。

回答 1 投票 0

回答 4 投票 0

std::chrono 和 cout

我有一个愚蠢的问题。我尝试切换到 c++11 标头,其中之一是 chrono。但我的问题是我无法计算出时间运算的结果。例如: 自动 t=std::chrono::

回答 5 投票 0

为作用域枚举类型调用重载位运算符时可能会返回无效值

该代码片段用于记录多个摄像机的状态。我为上述范围枚举重载了几个位运算符。 下面的代码片段运行良好。 虽然我清楚地知道...

回答 1 投票 0

我们应该删除这段代码中的移动构造函数和赋值吗?

在此代码中,On_heap 是管理堆上对象的包装器。是否必须删除此处的移动构造函数和赋值? 模板 结构On_heap { On_heap() :p(new T) { } //

回答 1 投票 0

为什么不使用 std::move 一切?

我不完全理解为什么我们不总是使用std::move? 例子; std::map 测试; void foo(std::map& 测试, int t1, int t2) { test.emplace(std::move(t1), s...

回答 1 投票 0

正确理解`CopyAssignable`

当我使用stl时,我发现不可分配的类型不允许作为容器的组件。 但是 CopyAssignable 概念确实很难掌握/理解,这需要深入研究

回答 1 投票 0

调试模板实例化

使用 C++ 模板进行元编程时,是否可以使用一种类似于调试器的方法来逐步了解模板的实例化和编译方式?看来是对的...

回答 4 投票 0

调用时出错:指定类型的对象过多 (PJ_ETOOMANY) [状态=70010]

我在我的 C++ 应用程序中使用 PJSIP 库来测试调用。当我尝试拨打超过 4 个电话时,我收到错误:太多指定类型的对象 (PJ_ETOOMANY) [status=70010]

回答 1 投票 0

为什么抛出移动构造函数会导致复制而不是在给出强异常保证的情况下移动?

我到处都看到,当移动构造函数为 noexcept(false) 时,标准库必须调用复制构造函数而不是移动构造函数。 现在我不明白...

回答 2 投票 0

错误:与“operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>”}和“void”不匹配)| [重复]

这是我的代码。我已经经历过很多次了,做了很多改变仍然是同样的错误。 #包括 使用命名空间 std; 无效 checkAge(int 年龄){ 如果(年龄 >= 18){ ...

回答 1 投票 0

错误:与“operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream<char>}”和“void”不匹配)

这是我的代码(我只写了本质),我得到了这个: 错误:与“operator<<’ (operand types are ‘std::ostream {aka std::basic_ostream}’ and ‘void’) class Mobil { public: void...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.