C ++是一种通用编程语言。它最初被设计为C的扩展,并保持类似的语法,但现在是一种完全不同的语言。使用此标记来查询有关使用C ++编译器编译的代码的问题。对特定标准版本[C ++ 11],[C ++ 17]等相关问题使用版本特定标记。
为什么我的 cmake 测试中没有使用 WORKING_DIRECTORY?
我正在尝试设置 CMake 测试的工作目录,但我似乎无法让它工作。这是我尝试使用的非常简单的测试: CMakeLists.txt cmake_minimum_required(版本3.24) 设置(
犰狳和 superLU 错误:“必须启用 SuperLU 的使用”和未定义的引用
对于一个项目,我需要使用armadillo给出的稀疏求解器,它似乎是SuperLU的包装器,我目前遇到一个问题。 您可能还会说我无权访问...
在 mac 中移动 clang include 目录中的外部头文件是否安全
在我的mac系统中,我已经通过homebrew安装了gnu-gcc、gnu-g++和apple-clang、apple-clang++,但随着时间的推移。我有些头文件在 apple-clang 中不可用,但在 gnu-gcc 中有...
我已经下载了犰狳6.5。它需要superLU(4.3)库来求解稀疏矩阵方程组。 我已经从这里下载了 superlu,但是当我想在 Windows 中制作它时,它给出: (...
在 C++11 中我们得到 constexpr: constexpr int foo (int x) { 返回x+1; } 是否可以使用动态值 x 来调用 foo 并引发编译时错误?也就是说,我想创建一个 foo...
我的操作系统 Windows 会跟踪时间和日期,它位于桌面的右下角。如果我想获取时间和日期,我希望有一个调用(可能是系统调用)来返回...
一个字符串文字应该被推导为 const char 数组,然后它会衰减为 const char* 指针。这就是为什么它有效: 结构MyStringView { 模板 MyStringView(常量
我对编程几乎完全陌生,我尝试学习 C++。这是我第一个感觉碰壁的任务。我尝试搜索,但因为人们通常使用循环来解决问题,所以我
我正在 DirectX 中开发简单的图形库。我使用 Dx 9 是因为我对它还很陌生,而且我找到了一本为第 9 版编写的很好的编程书。无论如何,我在屏幕上什么也看不到
模板 静态字符串类型 MyToString() { std::string s; 返回 s; } int main() { MyToString(); // 没有函数模板实例与 AR 匹配...
#包括 模板 结构体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 个主要编译器接受。 演示。
我可以在 C++ 中内联定义函数吗?我说的是 lambda 函数,而不是导致编译器优化的内联关键字。
我想将当前时间转换为字符串,以便稍后使用WM_PAINT中的Drawtext函数显示它。格式为时:分:秒。 以及获得时间稍后转弯的最方便的方法是什么...
前提:我希望我的 C++ 应用程序不依赖于任何 Microsoft Visual C++ 可再发行组件,这样我就可以提供开箱即用的可执行文件。 我首先做了什么:切换...
这个所谓的重复解释了为什么不允许这样做的机制,并显示了它无法工作的极端情况,但未能解决为什么 C++ 在这种情况下拒绝允许它的问题...
使用 CMake 混合 C++ 和 Objective-C 代码并获得 C++ 可执行文件
想法 我正在尝试用 C++ 实现游戏引擎。 我使用 macOS 进行开发(arm-64 架构)。我想使用 Foundation 框架创建一个窗口。 CMakeLists.txt 使用 C++ 和