standards

The apparent underspecification of one-past-the-end subscripting: for both raw arrays and std::vector. Has it been resolved decisively already?

☆樱花仙子☆ 提交于 2019-12-19 09:36:56
问题 It has been asked before in various forms, but since the language specification appears to be quite dynamic in this regard (or at least was dynamic when some SO discussions of this matter took place), it might make sense to revisit the matter in light of any more recent developments, if any exist. So, the question is, again, whether a combination of & and subscript is a valid way to obtain a pointer to the imaginary past-the-end element of an array int a[42] = {}; &a[42]; It was considered

Is conversion int -> unsigned long long defined by the standard

社会主义新天地 提交于 2019-12-19 09:18:51
问题 I can't find the exact specification of how int value is converted to unsigned long long in the standard. Various similar conversions, such as int -> unsigned, unsigned -> int (UB if negative), unsigned long long -> int, etc. are specified For example GCC, -1 is converted to 0xffffffffffffffff , not to 0x00000000ffffffff . Can I rely on this behavior? 回答1: Yes, this is well defined, it is basically adding max unsigned long long + 1 to -1 which will always be max unsigned long long . This is

What does “see below” mean when used as a type or exception specification?

余生颓废 提交于 2019-12-19 08:59:36
问题 Looking through the C++ standard ( current draft http://isocpp.org/files/papers/N3690.pdf, sec 20.8.3 is one such place) and through LLVM's libc++ headers, I've found "see below" used as a type and exception specification. It seems to be used when no type exists, but it seemed strange to use a 2 word phrase for that instead of some sort of valid identifier. Is it discussed somewhere in the standard or elsewhere? Why/how is it used? 回答1: see below is simply a place holder for one of a few

How to get wifi standard

孤者浪人 提交于 2019-12-19 07:47:19
问题 How can I get and change wifi standard, which I'm using now in my android device. For example: IEEE 802.11b or IEEE 802.11g or IEEE 802.11n. If this is possible. 回答1: Its not possible to get what type of network the phone is connected to. However you can find the speed of the network: WifiManager wifiManager = Context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { Integer linkSpeed = wifiInfo.getLinkSpeed(); //measured

How to get wifi standard

笑着哭i 提交于 2019-12-19 07:47:11
问题 How can I get and change wifi standard, which I'm using now in my android device. For example: IEEE 802.11b or IEEE 802.11g or IEEE 802.11n. If this is possible. 回答1: Its not possible to get what type of network the phone is connected to. However you can find the speed of the network: WifiManager wifiManager = Context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { Integer linkSpeed = wifiInfo.getLinkSpeed(); //measured

Why can you assign nullptr to std::string?

别等时光非礼了梦想. 提交于 2019-12-19 07:07:22
问题 So today I wrote a fairly hard to find bug where I initialized a std::string to nullptr (not a pointer to std::string, but the value itself). I've found apparently it's only possible to do in C++11 or later with clang. #include <string> #include <iostream> using namespace std; class Meh{ int x; }; class Foo { private: std::string x=nullptr; Meh y=nullptr; //remove this line and it compiles public: std::string z=nullptr; }; int main(void) { Foo f; cout << f.z; return 0; } As you can see, I

javascript name vs ID

限于喜欢 提交于 2019-12-19 06:29:31
问题 As far as I know there are two ways to get the value from a textbox either document.formName.textboxName.value; or document.getElementbyId('textboxId').value; As I understand using form name would mean I have less code to write, as name can be used for posting data and getting the value (apart from using ajax). As where if I was just posting using a standard form I would use name to post but I cannot use id ? e.g. in php I would use $_POST['texboxName']; If I where to have and ID on the

C++ Standard: Unexpected const_iterator in multiset

杀马特。学长 韩版系。学妹 提交于 2019-12-19 06:27:08
问题 I recently ran into an odd issue where I'd get a const_iterator instead of the expected iterator when iterating through a multiset. It turned out to be a non-issue for MSVC but g++ gave me an error: error: invalid initialization of reference of type 'myPtr&' from expression of type 'const boost::shared_ptr' Relevant code: typedef std::multiset<myPtr> myList; myList _mystuff; void tick(float dt) { for (myList::iterator i = _mystuff.begin(); i != _mystuff.end(); ++i) { myPtr &mine = *i; // g++

Correct behaviour of trivial statements involving expressions with volatile variables?

你说的曾经没有我的故事 提交于 2019-12-19 05:45:19
问题 Consider the following statements volatile int a = 7; a; // statement A volatile int* b = &a; *b; // statement B volatile int& c = a; c; // statement C Now, I've been trying to find a point in the standard that tells me how a compiler is to behave when coming across these statements. All I could find is that A (and possibly C) gives me an lvalue, and so does B: "§ 5.1.1.8 Primary expressions - General" says An identifier is an id-expression provided it has been suitably declared (Clause 7). [

What is an unnamed type in C++?

情到浓时终转凉″ 提交于 2019-12-19 05:25:11
问题 As part of my toilet reading on the C++ Standard ANSI ISO IEC 14882 2003, I came across the following: 14.3.1.2: A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as a template-argument for a template type-parameter. While I get what a local type and a compound type are, what is an unnamed type? If a type is unnamed, how could you even attempt to use it in a template anyway, which prompted the standard to verbally exclude it?