Git Product home page Git Product logo

Comments (5)

pezy avatar pezy commented on May 23, 2024

Hi~ @frank67 You are absolutely right. 👍

Could you please propose a pull request for this?

from cpp-primer.

frank67 avatar frank67 commented on May 23, 2024

@pezy maybe when @Mooophy wrote that code he want to declare a new reference to "i" the same way he had declared "r" in the "int i = 0, &r = i;" statements but it's also legal to declare a reference ("d") to another reference ("r") as I proposed.
HTH 😄

from cpp-primer.

pezy avatar pezy commented on May 23, 2024

@frank67 I have to say, @Mooophy is innocent... 😞

This confused answer is wrote by me, and I think I need to give some explanations:

  1. auto: deduce from the r-value's type. but essentially, thus reference and top-level const are ignored.
  2. decltype: deduce from the expression's type, and comprehensive, thus, including both reference and top-level const.

Then, come back this question, give example for difference:

decltype(r) d = i;
         ^^
     here is the key, i or r (right-hand operand of an assignment) is not the point.

So, IMHO, i or r is all okay. 🌝

from cpp-primer.

frank67 avatar frank67 commented on May 23, 2024

@pezy but "d" should it be a reference to "i" or "r" in that contest? Since it's legal to declare a reference to another reference for sake of clarity, since "r" was used in previous "c" assignement, I think "d" should be declared as reference of "r".:blush:

from cpp-primer.

pezy avatar pezy commented on May 23, 2024

@frank67 Agree. 👌

from cpp-primer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.