standards

ISO Standard Street Addresses?

此生再无相见时 提交于 2019-11-27 13:52:43
问题 Is there an ISO standard address format? I can't seem to find one, and I'd like to know for object- and database-design purposes. (One interesting document that shows a bunch of formats is this: http://www.bitboost.com/ref/international-address-formats.html, but it's insane!) 回答1: No; each country defines its own standard. There have been a number of questions about this in times past, including: Best practices for storing postal addresses in an RDBMS Is there a common street address database

Why do const references extend the lifetime of rvalues?

℡╲_俬逩灬. 提交于 2019-11-27 13:47:55
问题 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

Can we apply content not explicitly cited from the normative references to the C++ standard?

人走茶凉 提交于 2019-11-27 13:34:40
In the C++11 standard( closest draft is N3337 ) section 1.2 Normative references says: The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies. but there are no guidelines on how to apply the references. The easy cases are when the C++11 explicitly refers back to a reference, for example in section 3.9.1 Fundamental types it says: [...]The signed and unsigned integer types shall satisfy the constraints

How to Implement URL Routing in PHP

跟風遠走 提交于 2019-11-27 13:33:15
问题 How to implement URL Routing in PHP. 回答1: If you use Apache you can do the URL routing via mod_rewrite. Small example: RewriteEngine On RewriteRule ^(dir1)/?(path2)? main.php?dir=$1&path=$2 That'll have any request like http://yoursite.com/dir1/path1 served by http://yoursite.com/main.php?dir=dir1&path=path2 More examples here. The other alternative have every request redirect to a single php file RewriteEngine On RewriteRule (.*) main.php?request=$1 and then to do it in code, where you can

Using ssize_t vs int

﹥>﹥吖頭↗ 提交于 2019-11-27 12:48:30
问题 Code I've got a function which I can write in one of the four possible ways: int do_or_die(int retval); int do_or_die(ssize_t retval); ssize_t do_or_die(int t retval); ssize_t do_or_die(ssize_t retval); And then it will be called with both of these ways for library functions: written = do_or_die(write(...)); // POSIX write returns ssize_t printed = do_or_die(printf(...)); // printf returns int Questions Which prototype should I use? What types should I give to written and printed ? I want to

What could C/C++ “lose” if they defined a standard ABI?

可紊 提交于 2019-11-27 12:22:52
The title says everything. I am talking about C/C++ specifically, because both consider this as "implementation issue". I think, defining a standard interface can ease building a module system on top of it, and many other good things. What could C/C++ "lose" if they defined a standard ABI? The freedom to implement things in the most natural way on each processor. I imagine that c in particular has conforming implementations on more different architectures than any other language. Abiding by a ABI optimized for the currently common, high-end, general-purpose CPUs would require unnatural

Should a collection of constants be placed in a class or interface?

為{幸葍}努か 提交于 2019-11-27 12:21:04
If I have a collection of static constants that I want to declare centrally so that they can be shared among various projects should they be put in a class or interface (Java). In the past I have seen them mostly put in a class but I started thinking that since the class will not and should not be instantiated maybe they would be better in an interface, but then again the interface should not be implemented by any classes, e.g. public class ErrorCodes { public static final String ERROR_1 = "-1"; public static final String ERROR_2 = "-2"; } or public interface ErrorCodes { public static final

List of platforms supported by the C standard

时光毁灭记忆、已成空白 提交于 2019-11-27 12:06:18
Does anyone know of any platforms supported by the C standard, for which there is still active development work, but which are: not 2's complement or the integer width is not 32 bits or 64 bits or some integer types have padding bits or if you worked on a 2's complement machine, the bit pattern with sign bit 1 and all value bits zero is not a valid negative number or integer conversion from signed to unsigned (and vice versa) is not via verbatim copying of bit patterns or right shift of integer is not arithmetic shift or the number of value bits in an unsigned type is not the number of value

Do string literals that end with a null-terminator contain an extra null-terminator?

我们两清 提交于 2019-11-27 11:53:32
问题 For example: char a[] = "abc\0"; Does standard C say that another byte of value 0 must be appended even if the string already has a zero at the end? So, is sizeof(a) equal to 4 or 5? 回答1: All string literals have an implicit null-terminator, irrespective of the content of the string. The standard (6.4.5 String Literals) says: A byte or code of value zero is appended to each multibyte character sequence that results from a string literal or literals. So, the string literal "abc\0" contains the

Defining a variable in the condition part of an if-statement?

℡╲_俬逩灬. 提交于 2019-11-27 11:52:09
问题 I was just shocked, that this is allowed: if( int* x = new int( 20 ) ) { std::cout << *x << "!\n"; // delete x; } else { std::cout << *x << "!!!\n"; // delete x; } // std:cout << *x; // error - x is not defined in this scope So, is this allowed by the standard or it's just a compiler extension? P.S. As there were several comments about this - please ignore that this example is "bad" or dangerous. I know what. This is just the first thing, that came to my mind, as an example. 回答1: This is