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


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

Re: Type conversion for hundreds of lines

Path csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c++
Subject Re: Type conversion for hundreds of lines
Date Wed, 12 Oct 2022 14:30:53 -0700
Organization None to speak of
Lines 26
Message-ID <87fsfs4tma.fsf@nosuchdomain.example.com> (permalink)
References <ti797c$1it17$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain
Injection-Info reader01.eternal-september.org; posting-host="40a80e675ec1aea557807be1b777153a"; logging-data="1673789"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VumzOvxH/fV4qP/VkAvc4"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock sha1:3NKjFtMO4uS0fb97WOfXngrp9y0= sha1:j/P2u+2SS7lNPcovtgYMendcx+M=
Xref csiph.com comp.lang.c++:86891

Show key headers only | View raw


JiiPee <kerrttuPoistaTama11@gmail.com> writes:
> I have been pondering this many times. I keep it short:
> If I have hundreds of lines like this:
>
> short a;
> std::vector<int> v;
> ...
> a = v.size();
>
> This gives a warning: "warning, assigning size_t to short".
> I know this can be fixed:
> a = static_cast<short>(v.size());
>
> but if we have hundreds of those lines, how would you fix this? Place
> a static cast in all of them? Of create some helper funktion to do
> this?

Why is `a` defined as a short and not as a size_t?

If there's a very good reason that `a` *needs* to be a short, it makes
sense to consider some kind of cast.  If not, just make it a size_t.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

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


Thread

Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-12 23:48 +0300
  Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-12 23:54 +0300
    Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-12 23:55 +0300
      Re: Type conversion for hundreds of lines Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-10-12 23:26 +0100
        Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 07:30 +0300
          Re: Type conversion for hundreds of lines Ben Bacarisse <ben.usenet@bsb.me.uk> - 2022-10-13 12:19 +0100
    Re: Type conversion for hundreds of lines Paavo Helde <eesnimi@osa.pri.ee> - 2022-10-13 00:37 +0300
      Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 07:34 +0300
        Re: Type conversion for hundreds of lines Paavo Helde <eesnimi@osa.pri.ee> - 2022-10-13 11:43 +0300
  Re: Type conversion for hundreds of lines Paavo Helde <eesnimi@osa.pri.ee> - 2022-10-13 00:27 +0300
    Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 07:24 +0300
      Re: Type conversion for hundreds of lines Paavo Helde <eesnimi@osa.pri.ee> - 2022-10-13 12:00 +0300
        Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 20:27 +0300
      Re: Type conversion for hundreds of lines David Brown <david.brown@hesbynett.no> - 2022-10-13 11:17 +0200
        Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 20:32 +0300
          Re: Type conversion for hundreds of lines Paavo Helde <eesnimi@osa.pri.ee> - 2022-10-13 21:13 +0300
            Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 21:28 +0300
          Re: Type conversion for hundreds of lines David Brown <david.brown@hesbynett.no> - 2022-10-13 23:10 +0200
          Re: Type conversion for hundreds of lines Mike Terry <news.dead.person.stones@darjeeling.plus.com> - 2022-10-13 22:36 +0100
            Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-14 07:29 +0300
  Re: Type conversion for hundreds of lines scott@slp53.sl.home (Scott Lurndal) - 2022-10-12 21:27 +0000
    Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 07:25 +0300
  Re: Type conversion for hundreds of lines Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-10-12 14:30 -0700
    Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 07:28 +0300
      Re: Type conversion for hundreds of lines "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-10-12 21:30 -0700
        Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 07:37 +0300
          Re: Type conversion for hundreds of lines "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-10-13 14:18 -0700
            Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-14 00:27 +0300
              Re: Type conversion for hundreds of lines "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-10-14 00:33 -0700
  Re: Type conversion for hundreds of lines Juha Nieminen <nospam@thanks.invalid> - 2022-10-13 07:52 +0000
    Re: Type conversion for hundreds of lines JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-10-13 20:35 +0300
  Re: Type conversion for hundreds of lines Frederick Virchanza Gotham <cauldwell.thomas@gmail.com> - 2022-10-14 01:43 -0700

csiph-web