standards

Can a conversion from double to int be written in portable C

老子叫甜甜 提交于 2019-11-29 03:08:11
I need to write function like double_to_int(double val, int *err) which would covert double val to integer when it's possible; otherwise report an error (NAN/INFs/OUT_OF_RANGE). so pseudo code implementation would look like: if isnan(val): err = ERR_NAN return 0 if val < MAX_INT: err = ERR_MINUS_INF return MIN_INT if ... return (int)val There are at least two similar questions on SO: in this answer it's solved in enough clean way, though it's C++ solution - in C we do not have portable digits for signed int. In this answer, it's explained why we cannot just check (val > INT_MAX || val < INT

Does inheriting constructors work with templates in C++0x?

◇◆丶佛笑我妖孽 提交于 2019-11-29 02:00:46
问题 In C++0x, you can use the using keyword to inherit constructors, like so: class B { B(int) {} }; class A : public B { using B::B; }; Which will implicitly declare an A(int) constructor. Does this work with templates? class B { B(int) {} }; template<class T> class A : public T { using T::T; }; Within T::T , I expect the compiler to figure out the left hand T since using the scope operator on template arguments is normal, but figuring out that the right hand T is the constructor is a special

Can I read the C++ 2011 FDIS anywhere?

眉间皱痕 提交于 2019-11-29 01:54:19
问题 I probably can't, but I really would like to. Can I read the C++ 2011 FDIS anywhere? 回答1: Post-C++11, Stefanus Du Toit (the new editor for the C++ standardization committee) is maintaining the standard draft on github. The github page states: These are the sources used to generate drafts of the C++ standard. These sources should not be considered an ISO publication, nor should documents generated from them unless officially adopted by the C++ working group (ISO/IEC JTC1/SC22/WG21). You can

Objective-C standards document

北城以北 提交于 2019-11-29 01:53:56
问题 I'm a C and C++ programmer trying to get started with Objective-C. I'm really bewildered, though, by the apparent total absence of a standards document for the language and standard library. I can understand that there's no ISO standard, but is there no reference document at all? And how is it that nobody seems very concerned about this state of affairs? (Admittedly, it's hard to Google for such a thing, because "reference", "document", and "standard" are all overloaded terms. So it's

Are colons allowed in URLs?

左心房为你撑大大i 提交于 2019-11-29 01:24:12
I thought using colons in URIs was "illegal". Then I saw that vimeo.com is using URIs like http://www.vimeo.com/tag:sample. What do you feel about the usage of colons in URIs? How do I make my Apache server work with the "colon" syntax because now it's throwing the "Access forbidden!" error when there is a colon in the first segment of the URI? Colons are allowed in the URI path. But you need to be careful when writing relative URI paths with a colon since it is not allowed when used like this: <a href="tag:sample"> In this case tag would be interpreted as the URI’s scheme. Instead you need to

Must a deleted constructor be private?

点点圈 提交于 2019-11-29 01:07:35
class A { public: A() = default; A(const A&) = delete; }; class A { public: A() = default; private: A(const A&) = delete; }; Are these two definitions always identical to each other in any cases? They are different only wrt the produced diagnostics . If you make it private , an additional and superfluous access violation is reported: class A { public: A() = default; private: A(const A&) = delete; }; int main() { A a; A a2=a; } results in the following additional output from GCC 4.8: main.cpp: In function 'int main()': main.cpp:6:5: error: 'A::A(const A&)' is private A(const A&) = delete; ^

Why isn't there a regular expression standard?

十年热恋 提交于 2019-11-29 01:00:00
I know there is the perl regex that is sort of a minor de facto standard, but why hasn't anyone come up with a universal set of standard symbols, syntax and behaviors? There is a standard by IEEE associated with the POSIX effort . The real question is "why doesn't everyone follow it" ? The answer is probably that it is not quite as complex as PCRE with respect to greedy matching and what not. Actually, there is a regular expression standard (POSIX), but it's crappy. So people extend their RE engine to fit the needs of their application. PCRE (Perl-compatible regular expressions) is a pseudo

Do minor currency units have a ISO standard?

旧时模样 提交于 2019-11-29 00:10:56
问题 ISO 4217 defines 3-letter currency symbols: EUR USD LKR GBP Do currencies' minor units (cent, pence) have a ISO or similar standard, too, that defines codes for those sub-units like ct p ? 回答1: The standard also defines the relationship between the major currency unit and any minor currency unit. Often, the minor currency unit has a value that is 1/100 of the major unit, but 1/1000 is also common. Some currencies do not have any minor currency unit at all. In others, the major currency unit

Is it time to start developing with HTML5? [closed]

给你一囗甜甜゛ 提交于 2019-11-28 23:23:51
From searching SO, this question was already asked, almost a year ago now. So now with the new FF, Opera, IE, is it finally time to start developing sites with HTML5 or is it still a little premature and will cause compatibility issues? Is using HTML5 just going to require us to use more and more JS on websites to 'trick' older browsers into working properly? If you add nice features to your site, it is possible it will be talked about and reach the news sites for some free publicity. Aside from that, It would make a good beta site and give you a head start for when it becomes the new

Why do const references extend the lifetime of rvalues?

不羁的心 提交于 2019-11-28 23:22:25
Why did the C++ committee decide that const references should extend the lifetime of temporaries? This fact has already been discussed extensively online, including here on stackoverflow. The definitive resource explaining that this is the case is probably this GoTW: GotW #88: A Candidate For the “Most Important const” What was the rationale for this language feature? Is it known? (The alternative would be that the lifetime of temporaries is not extended by any references.) My own pet theory for the rationale is that this behavior allows objects to hide implementation details. With this rule,