在 c++ 中,函数 structname (void){num_threads = std::thread::hard
What is the function structname (void){num_threads = std::thread::hardware_concurrency();} for in c++? How can I understand it?
当我在我感兴趣的项目中阅读代码时,我遇到了没有函数名称的结构中的函数,也许它也不是lambda表达式capture->return-type{body},我只是不知道这个函数是什么样的?
// file.cc
struct AppSettings
{
std::string mesh_name;
std::size_t num_threads;
AppSettings (void)
{
num_threads = std::thread::hardware_concurrency();
}
};
任何人都知道我应该如何理解这个函数
AppSettings (void) {num_threads = std::thread::hardware_concurrency();}
?
这是类的构造函数。
这是一个特殊的成员函数,在实例化类的实例时自动执行。
给它参数列表(void)
是给它参数列表()
的老式方法,即没有参数。
有关更多信息,请参阅C++书中有关类的章节(请记住,struct
引入了类)。
相关文章:
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- C++ Win32 Threads
- Threads with Classes and std::packaged_task
- 包含 std::threads 的元素向量
- 这是在传递 int num 时创建搜索函数的正确方法吗?使用链表库
- C++:此代码可以编译,但引发运行时检查失败 #2 - 围绕变量周围的堆栈'num'已损坏。发生
- C++ Python 循环"for i, num in enumerate(list):"版本
- 为什么 C++ 中的 THREADS 在执行时给出不同的输出?
- 我无法创建 Poco::Threads 的向量
- 如果我从single_digits[*num - '0']]中删除'0',为什么这个程序会崩溃)
- 如何在 <threads> c++ 中使用和一维数组进行矩阵乘法?
- "a = new arr ***[num];"的含义是什么?
- 初始化时 num 的哪个值会给这个嵌套循环一个"true"输出?
- 语句中分配给 num 的值是什么
- 计算数的素数除数之和(非异数)直到 num 的有效替代方案
- 如何在Windows C MFC应用程序状态栏中禁用CAP NUM SCRL指示器
- 平台特定的std :: chrono :: high_resolution_clock :: ofence :: num
- 由于 RPTR->num=30 与 (*rptr).num=30 相同,但是*((*rptr).ptr).name 不起作用为什么?
- Threads within C++ class
- 如何中断其他 std::threads c++