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


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

Re: reference to reference (Type &&)

From MarioCPPP <NoliMihiFrangereMentulam@libero.it>
Newsgroups comp.lang.c++
Subject Re: reference to reference (Type &&)
Date 2023-03-06 23:22 +0100
Organization A noiseless patient Spider
Message-ID <tu5p3e$31uv$1@dont-email.me> (permalink)
References <tu2f60$1cnvt$2@dont-email.me> <tu5np6$2qqc$1@dont-email.me>

Show all headers | View raw


On 06/03/23 23:00, Andrey Tarasevich wrote:
> On 03/05/23 8:14 AM, MarioCPPP wrote:
>> But a Type && seems to be also able to point to ... to what ?
>> What is for ?
> 
> `&&` should be perceived as a monolithic token, not a 
> "reference to reference". It is just a special kind of 
> reference known as "rvalue reference".
> 
> A formal answer for what it is would be: It is special kind 
> of reference that is shoehorned into the C++ type system 
> with its own initialization and overload resolution rules. 
> Find the specification, read these rules and use this kind 
> of reference whenever it works for you.
> 
> A more human-friendly answer might sound as follows: The 
> whole thing was designed with one specific purpose in mind: 
> move semantics. You can use rvalue references and their 
> properties to elegantly implement move semantics. Note that 
> move semantics is not a core-language concept, it is 
> something you implement yourself, manually, by taking 
> advantage of rvalue references' properties. Find a book on 
> modern C++, read about move semantics.
> 
> Finally, rvalue references can be useful for other purposes, 
> not just for their primary purpose (i.e. move semantics), so 
> you can feel free to use them wherever you consider 
> appropriate.
> 

now ... with the suggestions from You and others in the 
thread, I am beginning to understand the very basic of what 
it is (I did not know an R-value could even have a reference 
... my fault !)

But I still cant'imagine its use.
I have to understand what is a MOVE SEMANTIC.

In my old-styled mind move IS copying (and deleting the 
original object).

Others said "to avoid DEEP copying", which is a concept I 
know, but still I am unable to connect with the R-value 
reference concept.

Anyway, I will try to study further to understand if this 
semantic will ever be useful to me.
Tnx to all



-- 
1) Resistere, resistere, resistere.
2) Se tutti pagano le tasse, le tasse le pagano tutti
MarioCPPP

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


Thread

reference to reference (Type &&) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-05 17:14 +0100
  Re: reference to reference (Type &&) Öö Tiib <ootiib@hot.ee> - 2023-03-05 22:24 -0800
  Re: reference to reference (Type &&) Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-06 12:53 +0200
  Re: reference to reference (Type &&) James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-03-06 14:31 -0500
  Re: reference to reference (Type &&) Andrey Tarasevich <andreytarasevich@hotmail.com> - 2023-03-06 14:00 -0800
    Re: reference to reference (Type &&) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-06 23:22 +0100
      Re: reference to reference (Type &&) James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-03-06 19:48 -0500
        Re: reference to reference (Type &&) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-07 12:19 +0100
      Re: reference to reference (Type &&) Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-03-07 03:48 -0800
        Re: reference to reference (Type &&) Öö Tiib <ootiib@hot.ee> - 2023-03-07 04:30 -0800
        Re: reference to reference (Type &&) Muttley@dastardlyhq.com - 2023-03-07 15:58 +0000
          Re: reference to reference (Type &&) Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-08 00:10 +0200
            Re: reference to reference (Type &&) Muttley@dastardlyhq.com - 2023-03-08 09:21 +0000
              Re: reference to reference (Type &&) Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-08 14:41 +0200
                Re: reference to reference (Type &&) Muttley@dastardlyhq.com - 2023-03-08 16:26 +0000
                Re: reference to reference (Type &&) "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-03-08 18:08 +0100
                Re: reference to reference (Type &&) Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-08 19:23 +0200
                Re: reference to reference (Type &&) Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-10 07:58 +0100
                Re: reference to reference (Type &&) MarioCPPP <NoliMihiFrangereMentulam@libero.it> - 2023-03-09 02:19 +0100

csiph-web