Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #70339

Re: enum type in template declaration

From Soviet_Mario <SovietMario@CCCP.MIR>
Newsgroups comp.lang.c++
Subject Re: enum type in template declaration
Date 2019-12-07 18:54 +0100
Organization A noiseless patient Spider
Message-ID <qsgp0a$kba$1@dont-email.me> (permalink)
References (3 earlier) <qsdib1$2j6$1@dont-email.me> <qsdv4a$fa2$1@dont-email.me> <qse6ma$1j7$1@dont-email.me> <qsei0f$7eo$1@dont-email.me> <qsem1j$unb$1@dont-email.me>

Show all headers | View raw


Il 06/12/19 23:51, Paavo Helde ha scritto:
> On 6.12.2019 23:42, Soviet_Mario wrote:
>>
>> uhm ... the allocation of proper types is known, but at 
>> "CODE-TIME" some
>> functions have duplexed code, and must know which part to 
>> use according
>> to the actual type of the container caller.
> 
> Sorry, I cannot make heads or tails out of your babble, but 
> as it seems you are fascinated by templates and not really 
> comprehending them, here are some general remarks about them 
> which might be helpful.
> 
> I know this can be confusing, but in C++ it is actually 
> pretty simple: templates are a compile-time feature. If you 
> need something to be solved by template mechanisms, it must 
> be known at compile time. And vice versa, if something is 
> only known only at run-time, you have to do it in an 
> old-fashioned run-time way - an if, a switch, etc.

yes, in fact the template function which cannot solve one 
aspect, has a switch.
But the control variable of the switch must be evaluated by 
ITS TYPE (or some internal ID, hash or other info associated 
to the type, not its value). In other words it must emulate 
sort of a virtual function selector.

Many other aspect of the generic container using a lot of 
common operators with a homogeneous semantic (assignments, 
overloaded by both, comparisons, idem) are instead managed 
by the container generically.

Indexing like an array but using operator () (row, column) 
instead is semantically different for container<double> and 
container<fixed_string>, the specialized versions do not 
have even the same number of parameters, the latter has a 
third parameter for index of character

I cannot explain well :\
anyway yes, there are lots of aspects of templates I miss to 
understand


> 
> hth
> 


-- 
1) Resistere, resistere, resistere.
2) Se tutti pagano le tasse, le tasse le pagano tutti
Soviet_Mario - (aka Gatto_Vizzato)

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

enum type in template declaration Soviet_Mario <SovietMario@CCCP.MIR> - 2019-12-05 23:20 +0100
  Re: enum type in template declaration James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-12-05 22:39 -0500
    Re: enum type in template declaration Soviet_Mario <SovietMario@CCCP.MIR> - 2019-12-06 13:15 +0100
      Re: enum type in template declaration Paavo Helde <myfirstname@osa.pri.ee> - 2019-12-06 14:42 +0200
        Re: enum type in template declaration Soviet_Mario <SovietMario@CCCP.MIR> - 2019-12-06 17:20 +0100
          Re: enum type in template declaration Paavo Helde <myfirstname@osa.pri.ee> - 2019-12-06 20:29 +0200
            Re: enum type in template declaration Soviet_Mario <SovietMario@CCCP.MIR> - 2019-12-06 22:42 +0100
              Re: enum type in template declaration Paavo Helde <myfirstname@osa.pri.ee> - 2019-12-07 00:51 +0200
                Re: enum type in template declaration Soviet_Mario <SovietMario@CCCP.MIR> - 2019-12-07 18:54 +0100
      Re: enum type in template declaration Öö Tiib <ootiib@hot.ee> - 2019-12-06 06:00 -0800
      Re: enum type in template declaration James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-12-06 09:56 -0500
      Re: enum type in template declaration Manfred <noname@add.invalid> - 2019-12-06 15:56 +0100
  Re: enum type in template declaration Soviet_Mario <SovietMario@CCCP.MIR> - 2019-12-06 18:43 +0100
  Re: enum type in template declaration saturnman2008@gmail.com - 2019-12-07 01:53 -0800
    Re: enum type in template declaration Soviet_Mario <SovietMario@CCCP.MIR> - 2019-12-07 18:57 +0100

csiph-web