SGI allocator

H

hpsoar

template <bool threads, int inst>
class __default_alloc_template { ... };
it is said that the 'inst' is never used, is that true? if so, then
why it was designed like that? thank you.
 
A

Alf P. Steinbach

* hpsoar:
template <bool threads, int inst>
class __default_alloc_template { ... };
it is said that the 'inst' is never used, is that true? if so, then
why it was designed like that? thank you.

If the information in the article's subject line is pertinent, why wasn't it
placed in the article itself?

Thank you,

- Alf
 
H

hpsoar

* hpsoar:


If the information in the article's subject line is pertinent, why wasn't it
placed in the article itself?

Thank you,

- Alf

It's a good link, but can anyone give me some explanation to my
question?
 
B

Bo Persson

hpsoar said:
template <bool threads, int inst>
class __default_alloc_template { ... };
it is said that the 'inst' is never used, is that true? if so, then
why it was designed like that? thank you.

It don't know in this case, but an int parameter is sometimes used to
create new types that behave the same, but are still different.

If the inst parameter is not used inside the template,
_default_alloc_template<true, 0> is different from
__default_alloc_template<true, 1>, but works the same.


Could perhaps sometimes be useful.


Bo Persson
 
J

James Kanze

template <bool threads, int inst>
class __default_alloc_template { ... };
it is said that the 'inst' is never used, is that true? if so, then
why it was designed like that?

It's really impossible to say without more context, But
generally, I would expect unused template parameters to occur in
the same sort of situations (transposed to templates, of course)
in which unused function arguments appear: the template must
conform to some "signature", which includes the parameter.
Thus, for example, if the template is designed so that it can be
used to instantiate something like:
template< template< bool, int > T > ...
, it must have two parameters, even if it doesn't use the
second.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top