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


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

Re: Function overloading

From Cholo Lennon <chololennon@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: Function overloading
Date 2022-07-30 18:03 -0300
Organization Aioe.org NNTP Server
Message-ID <tc46bn$1ths$1@gioia.aioe.org> (permalink)
References (1 earlier) <tba68s$1uiit$1@dont-email.me> <tbf95m$fc1$1@gioia.aioe.org> <tbfcei$3eapa$1@dont-email.me> <tbihhd$1gi1$1@gioia.aioe.org> <tbn0c2$1emem$2@dont-email.me>

Show all headers | View raw


On 7/25/22 18:01, Lynn McGuire wrote:
> On 7/23/2022 11:24 PM, Cholo Lennon wrote:
>> On 7/22/22 20:38, Lynn McGuire wrote:
>>> On 7/22/2022 5:43 PM, Cholo Lennon wrote:
>>>> On 7/20/22 9:22 PM, Lynn McGuire wrote:
>>>>> I use function overloading extensively in my C++ code code.   Works 
>>>>> great and it is useful to have the same name with different 
>>>>> arguments in many classes.  Here is one of my helper functions, tuple:
>>>>>
>>>>> std::vector <int> tuple ();
>>>>> std::vector <int> tuple (int int1);
>>>>> std::vector <int> tuple (int int1, int int2);
>>>>> std::vector <int> tuple (int int1, int int2, int int3);
>>>>> std::vector <int> tuple (int int1, int int2, int int3, int int4);
>>>>> std::vector <int> tuple (int int1, int int2, int int3, int int4, 
>>>>> int int5);
>>>>> std::vector <int> tuple (int int1, int int2, int int3, int int4, 
>>>>> int int5, int int6);
>>>>> std::vector <int> tuple (int int1, int int2, int int3, int int4, 
>>>>> int int5, int int6, int int7);
>>>>> std::vector <int> tuple (int int1, int int2, int int3, int int4, 
>>>>> int int5, int int6, int int7, int int8);
>>>>> std::vector <int> tuple (int int1, int int2, int int3, int int4, 
>>>>> int int5, int int6, int int7, int int8, int int9);
>>>>> std::vector <int> tuple (int int1, int int2, int int3, int int4, 
>>>>> int int5, int int6, int int7, int int8, int int9, int int10);
>>>>>
>>>>> and so on to int60.  I also have tupleString and tupleTuple.
>>>>
>>>> I suppose your code was written before C++11. Nowadays I would write 
>>>> something like this:
>>>>
>>>>      template<typename T>
>>>>      auto tuple() -> std::vector<T> {
>>>>          return std::vector<T>{};
>>>>      }
>>>>
>>>>      template<typename T, typename... Args>
>>>>      auto tuple(const T& first, const Args&... args) -> 
>>>> std::vector<T> {
>>>>          return std::vector<T>{ first, args... };
>>>>      }
>>>>
>>>> Or just use std::vector list initializer as suggested by Gawr Gura.
>>>>
>>>>
>>>> -- 
>>>> Cholo Lennon
>>>> Bs.As.
>>>> ARG
>>>
>>> My tuple functions were written in 2002 in my port from Smalltalk to 
>>> C++.  Did std::vector have an initializer back then ? 
>>
>> Why the rhetoric question? (both know that std::vector hadn't that in 
>> 2002). I explicitly said "I suppose your code was written before 
>> C++11. Nowadays I would write...".
>>
>>
>> -- 
>> Cholo Lennon
>> Bs.As.
>> ARG
> 
> Sorry, I do not remember when new features came into languages.  I have 
> written software in ten computer languages now.  I am approaching a 
> million lines of code now, it is hard to remember details.
> 

Thanks for the clarification, I wrongly assumed that in this newsgroup, 
everyone knows more or less, when some features where implemented.

Regards

--
Cholo Lennon
Bs.As.
ARG

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


Thread

Function overloading Cholo Lennon <chololennon@hotmail.com> - 2022-07-20 18:42 -0300
  Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-07-20 19:22 -0500
    Re: Function overloading Gawr Gura <gawrgura@mail.hololive.com> - 2022-07-20 22:44 -0700
      Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-07-21 16:17 -0500
    Re: Function overloading Cholo Lennon <chololennon@hotmail.com> - 2022-07-22 19:43 -0300
      Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-07-22 18:38 -0500
        Re: Function overloading Cholo Lennon <chololennon@hotmail.com> - 2022-07-24 01:24 -0300
          Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-07-25 16:01 -0500
            Re: Function overloading "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-07-26 00:05 +0200
              Re: Function overloading Cholo Lennon <chololennon@hotmail.com> - 2022-07-30 18:04 -0300
            Re: Function overloading Cholo Lennon <chololennon@hotmail.com> - 2022-07-30 18:03 -0300
              Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-08-02 23:11 -0500
    Re: Function overloading Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-27 16:10 +0200
      Re: Function overloading Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-27 16:11 +0200
      Re: Function overloading Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-27 16:35 +0200
        Re: Function overloading Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-28 05:51 +0200
      Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-07-27 14:54 -0500
        Re: Function overloading Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-28 05:43 +0200
          Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-07-28 13:32 -0500
      Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-07-27 15:01 -0500
  Re: Function overloading Juha Nieminen <nospam@thanks.invalid> - 2022-07-21 05:45 +0000
  Re: Function overloading Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-21 09:04 +0300
    Re: Function overloading Juha Nieminen <nospam@thanks.invalid> - 2022-07-21 07:16 +0000
      Re: Function overloading Lynn McGuire <lynnmcguire5@gmail.com> - 2022-07-21 16:22 -0500

csiph-web