Correct me if I am wrong, int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31) long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31) What is the difference in C++? Can they be used interchangeably? It is implementation dependent. For example, under Windows they are the same, but for example on Alpha systems a long was 64 bits
纠正我,如果我错了, int是4个字节,范围从-2,147,483,648到2,147,483,647(2 ^ 31) 长为4个字节,范围从-2,147,483,648到2,147,483,647(2 ^ 31) C ++有什么区别? 它们可以互换使用吗? 它依赖于实现。 例如,在Windows下它们是相同的,但是例如在Alpha系统上,长度是64位,而int是32位。 本文介绍了可变平台上的英特尔C ++编译器规则。 总结: OS arch size Windows IA-32
I used to do all my Linux profiling with gprof. However, with my multi-threaded application, it's output appears to be inconsistent. Now, I dug this up: http://sam.zoy.org/writings/programming/gprof.html However, it's from a long time ago and in my gprof output, it appears my gprof is listing functions used by non-main threads. So, my questions are: 1) In 2010, can I easily us
我曾经用gprof来完成我所有的Linux分析。 但是,使用我的多线程应用程序,它的输出看起来不一致。 现在,我挖了这个: http://sam.zoy.org/writings/programming/gprof.html 但是,从很久以前,在我的gprof输出中,似乎我的gprof列出了非主线程使用的函数。 所以,我的问题是: 1)2010年,我可以轻松使用gprof来分析多线程Linux C ++应用程序吗? (Ubuntu 9.10)2)我应该考虑哪些其他工具来进行分析? 编辑:
C++17 is now feature complete, so unlikely to experience large changes. Hundreds of proposals were put forward for C++17. Which of those features were added to C++ in C++17? When using a C++ compiler that supports "C++1z", which of those features are going to be available when the compiler updates to C++17? Language features: Templates and Generic Code Template argument deduc
C ++ 17现在功能完整,所以不太可能遇到大的变化。 针对C ++ 17提出了数百个提案。 在C ++ 17中,哪些功能被添加到C ++中? 当使用支持“C ++ 1z”的C ++编译器时,当编译器更新到C ++ 17时,哪些功能将可用? 语言特点: 模板和通用代码 类模板的模板参数推导 就像函数如何推导模板参数一样,现在构造函数可以推导出该类的模板参数 http://wg21.link/p0433r2 http://wg21.link/p0620r0 http://wg21.link/p0512r0
What is a lambda expression in C++11? When would I use one? What class of problem do they solve that wasn't possible prior to their introduction? A few examples, and use cases would be useful. The problem C++ includes useful generic functions like std::for_each and std::transform , which can be very handy. Unfortunately they can also be quite cumbersome to use, particularly if the fu
什么是C ++ 11中的lambda表达式? 我什么时候可以用一个? 在他们推出之前,他们解决的哪类问题是不可能的? 一些例子和用例会很有用。 问题 C ++包含有用的通用函数,如std::for_each和std::transform ,它们可以非常方便。 不幸的是,它们的使用也很麻烦,特别是如果您想要应用的函数对于特定函数是独一无二的。 #include <algorithm> #include <vector> namespace { struct f { void operator()(
I just finished listening to the Software Engineering radio podcast interview with Scott Meyers regarding C++0x. Most of the new features made sense to me, and I am actually excited about C++0x now, with the exception of one. I still don't get move semantics... What are they exactly? I find it easiest to understand move semantics with example code. Let's start with a very simple stri
我刚刚听完了关于C ++ 0x的关于Scott Meyers的软件工程无线电播客采访。 大部分新功能对我来说都很有意义,而且我现在对C ++ 0x感到非常兴奋,除了一个。 我仍然没有得到移动语义...他们究竟是什么? 我发现使用示例代码理解移动语义是最容易的。 让我们从一个非常简单的字符串类开始,它只保存一个指向堆分配内存块的指针: #include <cstring> #include <algorithm> class string { char* data; public
I was having a look through some open source C++ code and notice a lot of double under scores where used in the code, mainly at the start of variable names. return __CYGWIN__; Just wondering is there a reason for this, or is it just some people code styles? I would think that I makes it hard to read. From Programming in C++, Rules and Recommendations : The use of two underscores (`__')
我正在浏览一些开源的C ++代码,并注意到代码中使用的分数下有很多double,主要是在变量名称的开头。 return __CYGWIN__; 只是想知道是否有这个原因,还是只是一些人的代码风格? 我会认为我很难阅读。 从C ++编程,规则和建议: 根据ANSI-C标准,在标识符中使用两个下划线(`__')被保留供编译器内部使用。 下划线(`_')通常用于库函数的名称(如“_main”和“_exit”)。 为避免冲突,请勿使用下划线开始标识符
std::is_pod will be probably deprecated in C++20. What's the reason for this choice? What should I use in place of std::is_pod to know if a type is actually a POD? POD is being replaced with two categories that give more nuances. The c++ standard meeting in november 2017 had this to say about it: Deprecating the notion of “plain old data” (POD). It has been replaced with two more nua
std::is_pod可能会在C ++ 20中被弃用。 这种选择的理由是什么? 我应该用什么来代替std::is_pod来知道类型是否实际上是POD? POD正在被两个类别取代,从而带来更多的细微差别。 2017年11月的c ++标准会议有这样的说法: 摒弃“普通旧数据”(POD)的概念。 它已被两种更细微的类型所取代,即“微不足道”和“标准版式”。 “POD”相当于“简单和标准布局”,但对于许多代码模式,对“简单”或“标准布局”的狭窄限制是适当的; 为了
This FAQ is about Aggregates and PODs and covers the following material: What are Aggregates ? What are POD s (Plain Old Data)? How are they related? How and why are they special? What changes for C++11? How to read: This article is rather long. If you want to know about both aggregates and PODs (Plain Old Data) take time and read it. If you are interested just in aggregates, read
本常见问题解答关于聚合和POD,并涵盖以下内容: 什么是聚合 ? 什么是POD (普通旧数据)? 他们有什么关系? 他们如何以及为何特别? C ++ 11有哪些变化? 如何阅读: 这篇文章相当长。 如果你想了解总量和POD(普通旧数据),请花点时间阅读。 如果您只对聚合体感兴趣,请阅读第一部分。 如果你只对POD感兴趣,那么你必须先阅读聚合的定义,含义和例子,然后你可以跳到POD,但我仍然建议阅读第一部分的全部
Could anyone explain the details in terms of rvalues, lvalues, PODs, and non-PODs the reason why the first expression marked below is not ok while the second expression marked below is ok? In my understanding both int() and A() should be rvalues, no? struct A {}; int main() { int i; A a; int() = i; //Not OK (error). A() = a; //OK. return 0; } Rvalues are what you get from expres
任何人都可以用右值,左值,POD和非POD来解释细节,下面标记的第一个表达式是不正确的,而下面的第二个表达式是正确的? 在我的理解中,int()和A()应该是右值,不是吗? struct A {}; int main() { int i; A a; int() = i; //Not OK (error). A() = a; //OK. return 0; } Rvalues是你从表达中得到的结果(从C标准中得到的有用的简化,但没有用C ++标准表达)。 左值是“定位值”。 左值可以用作右值。 引
Possible Duplicate: The Definitive C++ Book Guide and List I have been reading "Jumping Into C++" by Alex Allain. I understood the first few chapters consisting on the basics, up through Functions. As soon as it started talking about passing variables to functions and continuing on to arrays, structures and enums I could not follow the book very easily. In fact only about 25% of
可能重复: 最终的C ++图书指南和列表 我一直在阅读Alex Allain的“跳入C ++”。 我通过函数了解了前几章的基础知识。 只要它开始谈论将变量传递给函数并继续使用数组,结构和枚举,我就无法很容易地跟随本书。 事实上,只有约25%的最后一章练习可以在没有找到其他人的答案的情况下完成。 我的问题是:是否有更好的关于C ++或在线参考的书可以继续我的自我教育? 我只是觉得它没有以我能理解的方式向我解释。 我不知道