Forum Replies Created

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • in reply to: Instantiating with {} or = #542487
    Antonella Ritorto
    Participant
        Up
        0
        Down
        ::

        Thanks a lot Hans, Diana, and Rainer for the detailed explanation and examples.

        in reply to: const pointer containg const #542486
        Antonella Ritorto
        Participant
            Up
            0
            Down
            ::

            Thanks you very much Driton and Rainer. I’m also using compiler explorer, but maybe I’m not choosing correctly the settings and that’s why I get other error messages. Thanks again!

            in reply to: Return preserves const? #542293
            Antonella Ritorto
            Participant
                Up
                0
                Down
                ::

                Many thanks for the example. It gives me a better understanding. So local variable var is captured and returned by the lambda-function returned when calling makeLambda(), but at the same time cannot go out of its scope. I hope I get it. Thanks again!

                in reply to: Adding char + int #484361
                Antonella Ritorto
                Participant
                    Up
                    0
                    Down
                    ::

                    Thanks, Dominik. I see the point now. Thanks for the reference to c++ representations!

                    in reply to: Adding char + int #484360
                    Antonella Ritorto
                    Participant
                        Up
                        0
                        Down
                        ::

                        Thanks, Kuci. Indeed, I used CppInsights. I understood it’s related to those implicit conversations but wanted to know why ‘a’ turns 97, instead of some other value. Probably it’s not as important as understanding how auto works with a template function, in the return type. Thanks again!

                        in reply to: Return preserves const? #484359
                        Antonella Ritorto
                        Participant
                            Up
                            0
                            Down
                            ::

                            Thank you very much for your response Kuci. May I ask what do you mean with lifetime of the object/variable you are returning the const& from? (I’m a beginner). Could it be that if I have something like:

                             

                            std::function<const std::string&(const std::string&)> func = 
                              [](const std::string& a){return a;};
                            
                            void print{
                             auto myValue = func(const std::string& a);
                            }
                            // myValue is dead here, isn't it? but any other local variable would be also dead...
                            

                             

                            Many thanks in advance!

                            in reply to: User-defined literal, overload operator #470814
                            Antonella Ritorto
                            Participant
                                Up
                                0
                                Down
                                ::

                                Thank you very much. I double-checked again, and now I do not get any error message. I used the command line g++ file.cpp -o file. It’s working now, both options: const double& n, or just double n.

                                Thanks again!

                                in reply to: User-defined literal, overload operator #452862
                                Antonella Ritorto
                                Participant
                                    Up
                                    0
                                    Down
                                    ::

                                    Thanks! That’s the correct code. The incorrect one would be to replace the piece:

                                    friend MyDistance operator *(double m, const MyDistance& b){
                                    return MyDistance(m*b.m);
                                    }

                                    by (my incorrect attempt):

                                    friend MyDistance operator *(double n, const MyDistance& b){ // const double& n
                                    return MyDistance(n*b.m);
                                    }

                                     

                                    in reply to: Type deduction: auto vs auto* (+/- const) #412141
                                    Antonella Ritorto
                                    Participant
                                        Up
                                        0
                                        Down
                                        ::

                                        Thank you very much to both Rainer and Kuci.

                                        in reply to: Antonella Ritorto #403164
                                        Antonella Ritorto
                                        Participant
                                            Up
                                            1
                                            Down
                                            ::

                                            Hi Diana! Nice to meet you and to hear we have kind of the same experience! Spanish-speakers women in Math/Industry :)

                                          Viewing 10 posts - 16 through 25 (of 25 total)