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


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

Re: Integer promotions, conversions, coercions and templates :(

From "MikeP" <mp011011@some.org>
Newsgroups comp.lang.c++
Subject Re: Integer promotions, conversions, coercions and templates :(
Date 2011-06-10 06:18 -0500
Organization A noiseless patient Spider
Message-ID <issuic$ui9$1@dont-email.me> (permalink)
References (5 earlier) <95clnbFqk0U1@mid.individual.net> <isr9cs$6j7$1@dont-email.me> <95cr43Fqk0U2@mid.individual.net> <isrglm$lh6$1@dont-email.me> <95d0f9Fqk0U4@mid.individual.net>

Show all headers | View raw


Ian Collins wrote:
> On 06/10/11 10:15 AM, MikeP wrote:
>> Ian Collins wrote:
>>
>>> Anyway, if you were using a
>>> macro you would have to have a parameter for the suffix.
>>
>> Yes, as I wanted with the template (for lack of any other way), but
>> templates won't allow it.
>
> Because they don't require it.  The type is known.
>
>> I thought I had it down for awhile, but I
>> hadn't yet called any of the member functions of the template class
>> so the code genrator did not generate code for those member
>> functions and everything seemed "way-kewl", until I wrote the test
>> and started calling the functions and then the compiler complained.
>> So, I can do what I wanted to do with the macro but not with the
>> template, and if I do it in "super macro" style, it may be a better
>> solution than jumping through hoops with the template "deficiency"
>> (TBD).
>
> Hoops?  What could be simpler than
>
> template <typename T>
> bool CheckBit( T mask, unsigned n)
> {
>   assert( n < std::numeric_limits<T>::digits );
>
>   return (mask & (T(1) << (n-1)));
> }
>
> bool result = CheckBit( 42ull, 4 );
>

I'm still concerned about any/all implicit transformations on the right 
side of "<<".  Any LL (Language Lawyer) care to enumerate those? A suffix 
on the literal would make things a bit easier to implement and grok, but 
again, they cannot be had in this scenario :( . The literal "starts out 
life as" a signed int? Then... 

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


Thread

Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-08 17:09 -0500
  Re: Integer promotions, conversions, coercions and templates :( Ian Collins <ian-news@hotmail.com> - 2011-06-09 10:22 +1200
    Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-08 17:49 -0500
    Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-08 19:13 -0500
      Re: Integer promotions, conversions, coercions and templates :( Ian Collins <ian-news@hotmail.com> - 2011-06-09 14:32 +1200
        Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-09 07:30 -0500
          Re: Integer promotions, conversions, coercions and templates :( Öö Tiib <ootiib@hot.ee> - 2011-06-09 06:18 -0700
            Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-09 08:45 -0500
              Re: Integer promotions, conversions, coercions and templates :( Öö Tiib <ootiib@hot.ee> - 2011-06-09 06:51 -0700
                Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-09 13:44 -0500
          Re: Integer promotions, conversions, coercions and templates :( Ian Collins <ian-news@hotmail.com> - 2011-06-10 07:37 +1200
            Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-09 15:11 -0500
              Re: Integer promotions, conversions, coercions and templates :( Ian Collins <ian-news@hotmail.com> - 2011-06-10 09:09 +1200
                Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-09 17:15 -0500
                Re: Integer promotions, conversions, coercions and templates :( Ian Collins <ian-news@hotmail.com> - 2011-06-10 10:40 +1200
                Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-10 05:07 -0500
                Re: Integer promotions, conversions, coercions and templates :( Öö Tiib <ootiib@hot.ee> - 2011-06-10 03:14 -0700
                Re: Integer promotions, conversions, coercions and templates :( Öö Tiib <ootiib@hot.ee> - 2011-06-10 03:19 -0700
                Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-10 06:08 -0500
                Re: Integer promotions, conversions, coercions and templates :( Öö Tiib <ootiib@hot.ee> - 2011-06-10 04:32 -0700
                Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-10 07:14 -0500
                Re: Integer promotions, conversions, coercions and templates :( Öö Tiib <ootiib@hot.ee> - 2011-06-10 05:27 -0700
                Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-10 07:35 -0500
                Re: Integer promotions, conversions, coercions and templates :( Öö Tiib <ootiib@hot.ee> - 2011-06-10 06:47 -0700
                Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-10 06:18 -0500
                Re: Integer promotions, conversions, coercions and templates :( Ian Collins <ian-news@hotmail.com> - 2011-06-11 08:08 +1200
                Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-10 18:41 -0500
    Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-10 08:11 -0500
  Re: Integer promotions, conversions, coercions and templates :( Öö Tiib <ootiib@hot.ee> - 2011-06-09 06:28 -0700
    Re: Integer promotions, conversions, coercions and templates :( "MikeP" <mp011011@some.org> - 2011-06-09 08:50 -0500
  Re: Integer promotions, conversions, coercions and templates :( (Summary so far) "MikeP" <mp011011@some.org> - 2011-06-10 08:40 -0500
    Re: Integer promotions, conversions, coercions and templates :( (Summary so far) Öö Tiib <ootiib@hot.ee> - 2011-06-10 07:14 -0700
      Re: Integer promotions, conversions, coercions and templates :( (Summary so far) "MikeP" <mp011011@some.org> - 2011-06-10 09:17 -0500
    Re: Integer promotions, conversions, coercions and templates :( (Summary so far)(Corrections and more) "MikeP" <mp011011@some.org> - 2011-06-10 09:14 -0500
      Re: Integer promotions, conversions, coercions and templates :( (Results: Generated Code) "MikeP" <mp011011@some.org> - 2011-06-10 12:43 -0500
  Re: Integer promotions, conversions, coercions and templates :( (Conclusion) "MikeP" <mp011011@some.org> - 2011-06-14 18:35 -0500
    Re: Integer promotions, conversions, coercions and templates :( (Conclusion) Ian Collins <ian-news@hotmail.com> - 2011-06-15 12:51 +1200
      Re: Integer promotions, conversions, coercions and templates :( (Conclusion) "MikeP" <mp011011@some.org> - 2011-06-15 08:45 -0500
    Re: Integer promotions, conversions, coercions and templates :( (Conclusion) Michael DOUBEZ <michael.doubez@free.fr> - 2011-06-15 03:33 -0700
      Re: Integer promotions, conversions, coercions and templates :( (Conclusion) "MikeP" <mp011011@some.org> - 2011-06-15 09:17 -0500
        Re: Integer promotions, conversions, coercions and templates :( (Conclusion) Michael DOUBEZ <michael.doubez@free.fr> - 2011-06-16 04:17 -0700
          Re: Integer promotions, conversions, coercions and templates :( (Conclusion) "MikeP" <mp011011@some.org> - 2011-06-16 09:45 -0500
            Re: Integer promotions, conversions, coercions and templates :( (Conclusion) Michael DOUBEZ <michael.doubez@free.fr> - 2011-06-17 01:56 -0700
              Re: Integer promotions, conversions, coercions and templates :( (Conclusion) "MikeP" <mp011011@some.org> - 2011-06-17 07:58 -0500
                Re: Integer promotions, conversions, coercions and templates :( (Conclusion) Michael DOUBEZ <michael.doubez@free.fr> - 2011-06-17 06:54 -0700
                Re: Integer promotions, conversions, coercions and templates :( (Conclusion) "MikeP" <mp011011@some.org> - 2011-06-17 09:19 -0500
              Re: Integer promotions, conversions, coercions and templates :( (Conclusion) "MikeP" <mp011011@some.org> - 2011-06-17 08:17 -0500
                Re: Integer promotions, conversions, coercions and templates :( (Conclusion) Michael DOUBEZ <michael.doubez@free.fr> - 2011-06-17 07:33 -0700
                Re: Integer promotions, conversions, coercions and templates :( (Conclusion) "MikeP" <mp011011@some.org> - 2011-06-17 09:49 -0500

csiph-web