On 11/29/2015 12:22 PM, Daniel N wrote:
On Sunday, 29 November 2015 at 10:58:48 UTC, Manu wrote:
On 29 November 2015 at 20:17, Iain Buclaw via Digitalmars-d
I think your idea with aliases was just wishful thinking, aliases
themselves never worked like that.
I thought aliases did produce a symbol in the scope they are declared?
Or do you mean with the private thing? Yeah...
Aliases are often used to sort out these sorts of scope/namespacing
issues, I've seen it come up lots of times.
I remember when this feature was under discussion, I tried to argue
against extern c++ creating a new scope, but alas no avail. So my
current workaround looks something like this(but I didn't use it on a
large scale yet):
private static struct Hidden
{
public:
extern(C++, std) int fun();
}
// autogenerate all aliases with 'static foreach'?
alias fun = Hidden.std.fun;
if only static foreach would get accepted one day...
It is mostly about implementation now (and figuring out a couple of
corner cases, for which the first version could just deny support).
Something like this seems to be enough for your needs though:
mixin({string s;
foreach(m;__traits(allMembers,std))
s~=`alias `~m~`=std.`~m~`;`;
return s;
}());