Using RefCounted in a pure function is impossible:
import std.typecons;
void main() pure {
RefCounted!int i;
}
-----
main.d(4): Error: pure function 'D main' cannot call impure function 'std.typecons.RefCounted!(int).RefCounted.~this'
-----
Nothing in RefCounted is marked as pure in general.
Comment #1 by monarchdodra — 2013-04-29T03:44:52Z
There is indeed a few mistakes in RefCounted which I can take care of.
I did hit this issue though:
"Error: pure function 'std.typecons.RefCounted!(int).RefCounted.~this' cannot call impure function 'core.stdc.stdlib.free'"
I can agree that "free" is not pure, as calling it twice on the same pointer will not yield the same result. However, there is no such thing as "trusted purity", so I'm not sure how to do that...
I'll ask on the boards.
Comment #2 by andrej.mitrovich — 2014-04-24T11:32:16Z