String literals have only one instance?

Sean Kelly sean at invisibleduck.org
Thu Aug 19 08:10:03 PDT 2010


Rory Mcguire Wrote:

> Are all string literals that have the same value initialized to the same 
> address?
> 
> void main() {
> 	string same() {
> 		return "This";
> 	}
> 	assert("This" is same());
> 	assert("This" is "This");
> }
> 
> 
> Can this be relied upon?

This should be expected but I wouldn't rely upon it.


More information about the Digitalmars-d-learn mailing list