Appender and CTFE
Steven Schveighoffer
schveiguy at yahoo.com
Thu Mar 3 09:06:40 PST 2011
On Thu, 03 Mar 2011 11:54:58 -0500, kenji hara <k.hara.pg at gmail.com> wrote:
> Even without performance issue, Appender is necessary because it
> configures output range.
>
> Currently std.array.put does not allow empty array as its argument.
> int[] arr = [];
> arr.put(1); // invalid. this does not means appending.
>
> Therefore building an array its length is not known beforehand
> requires Appender.
Performance really is the only issue, the complexity of Appender is not
necessary for your issue. One could make a very simple appender struct if
creating a proper output range was the only problem:
struct appender(T)
{
T[] data;
void put(T t) { data ~= t; }
}
-Steve
More information about the Digitalmars-d
mailing list