digitalmars.D.learn - std.array.Appender with fixed size arrays
- Richard Webb (17/17) Jun 08 2010 Hi,
- bearophile (4/11) Jun 08 2010 Maybe it's not a bug, but it's a limitation. With some more work on the ...
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/28) Jun 08 2010 The problem is due to a relatively recent change to D2: the size of
Hi, While trying to get some things to build in D2, i noticed that the code: //////////////////// import std.array; void main (string[] args) { string s; auto app = appender(&s); app.put(['a', 'b']); } ///////////////////// works, but if it's changed to; char[2] tmp = ['a', 'b']; app.put(tmp); then it fails. Seems to be because char[2] isn't a forward range, so it doesn't match the version of put that takes a range. Is this a bug?
Jun 08 2010
Richard Webb:char[2] tmp = ['a', 'b']; app.put(tmp); then it fails. Seems to be because char[2] isn't a forward range, so it doesn't match the version of put that takes a range. Is this a bug?Maybe it's not a bug, but it's a limitation. With some more work on the Appender then this limit can be removed. If you want you can fix the problem and submit a patch in bugzilla. Probably it's not too much hard to do. Bye, bearophile
Jun 08 2010
Richard Webb wrote:Hi, While trying to get some things to build in D2, i noticed that the code: //////////////////// import std.array; void main (string[] args) { string s; auto app = appender(&s); app.put(['a', 'b']); } ///////////////////// works, but if it's changed to; char[2] tmp = ['a', 'b']; app.put(tmp); then it fails. Seems to be because char[2] isn't a forward range, so it doesn't match the version of put that takes a range. Is this a bug?The problem is due to a relatively recent change to D2: the size of fixed sized arrays may not be changed. (I like how it fits their name. :) ) Ali
Jun 08 2010