On Wednesday, 6 July 2016 at 06:43:13 UTC, ZombineDev wrote:
Using mixin templates you can get the behavior you want to some extent, with exception that you need to type "mixin" in front when you're instantiating them.

I wonder if reusing the mixin statement for normal templates would be a good idea to reuse existing code while allowing access to private members.

I thought about that, but the problem affects things like emplace as well and I somehow doubt that we are going to turn emplace into a mixin template.

I think there needs to be some kind of opt-in attribute to indicate that the template should use the instantiating module's access rights. There are three things it would need to do...

1) It would need to cause the template instantiation to have the same access rights as the instantiating module.

2) It would need to tie the instantiation to the instantiating module, different module will have different access rights so the templates won't match.

3) It would need to transmit these access rights through other templates if they also have the opt-in attribute. All the templates would have the instantiating scopes access rights. It would be needed in cases like allocator.make which ends up calling emplace eventually. The access rights would need to be transmitted all the way to emplace.

The attribute could be argument specific or applied to the whole template, I am not sure which would be better but they could both work.

Reply via email to