Templates - What's Up with the template keyword?
Ron Tarrant
rontarrant at gmail.com
Tue Apr 9 10:53:49 UTC 2019
On Monday, 8 April 2019 at 14:56:46 UTC, Mike Parker wrote:
> In the subsequent sections, I show both long and short
> (eponymous) forms of enum and function templates.
In your book, Mike, you stated:
> Remember, a template is only instantiated once for each set of
> arguments and
> the same instantiation can be repeated in multiple modules
> throughout a
> program. If each instantiation were scoped locally, the
> template would no
> longer work as expected.
That leads me to speculate that it should be possible to use a
class template as a sort of singleton. But, because a class
template (from what I understand currently) needs to be
instantiated using 'new,' I'm thinking maybe it isn't possible.
Can you (or someone else) clear this up for me, please?
What I have in mind is a template wrapped around a GTK AccelGroup
that could then be instantiated in the MainWindow as well as
inside any MenuItem needing a keyboard shortcut assignment.
More information about the Digitalmars-d-learn
mailing list