On 4/26/14, 11:13 PM, Brian Schott wrote:
There are quite a few places where functions could be marked pure,
nothrow, @safe, or @trusted that have not been. I have a pull request
open for many of these.
Thanks!
I also have a feature request. I think something like this should be
added to std.allocator:
/**
* Shortcut that encapsulates a cast and a call to emplace()
* Params:
* a = the allocator to use
* args = the arguments to $(D T)'s constructor
* Returns: a pointer to an instance of $(D T).
*/
T* allocate(T, Allocator, Args...)(auto ref Allocator a, auto ref Args
args)
@trusted if (is (T == struct))
{
import std.conv : emplace;
void[] mem = a.allocate(T.sizeof);
return emplace(cast(T*) mem.ptr, args);
}
The allocate-cast-initialize pattern is incredibly common in the code
that I've written using allocators so far and I'd like it to be in
Phobos so that it does not need to be re-implemented everywhere.
Totally. That will be part of typed allocators, module that's now empty :o).
Andrei