Forum Replies Created

Viewing 11 posts - 31 through 41 (of 41 total)
  • Author
    Posts
  • in reply to: mutable attributes #66320
    diana
    Participant
        Up
        0
        Down
        ::

        Right. I had in mind a multi-threaded environment where you also want to keep a cache. Looking forward to the weeks about threading.

        in reply to: mutable attributes #66315
        diana
        Participant
            Up
            0
            Down
            ::

            I read that another application of mutable is to declare a member variable mutable if we want to use it to cache the result of an expensive calculation. In that application should we still use a mutex to make sure that other threads are not updating the cache at the same time?

            in reply to: Carbon language, as a possible C++ successor #64485
            diana
            Participant
                Up
                0
                Down
                ::

                In case you want to join after the Q&A, there is a live chat now on YouTube as people watch the premier of Chandler’s Carbon talk.

                in reply to: Carbon language, as a possible C++ successor #64470
                diana
                Participant
                    Up
                    0
                    Down
                    ::

                    I likely won’t make it to the Q&A today as I may not be in range of Wifi at that time. Good news is that we are working to get the video out today. If you all subscribe to CppNorth’s YouTube channel you’ll be first to know when the video is out: https://youtube.com/channel/UCGWAlXciy785Iog-X7247Hw

                    in reply to: Overload new and delete #56657
                    diana
                    Participant
                        Up
                        0
                        Down
                        ::

                        Thanks for the pointers Rainer! Yes I think since only I see it, only I can investigate what is happening. I’ll let you know if I find something interesting.

                        in reply to: Overload new and delete #56174
                        diana
                        Participant
                            Up
                            0
                            Down
                            ::

                            I am using gcc 11.3.0, rev 1 built by MSYS2 project.

                            It is very odd because when I compile this code in compiler explorer with gcc 11.3 I get 6 allocations and 4 deallocations as expected: https://godbolt.org/z/bK5z8vqb7

                            But when I compile the same exact code locally I get the output:

                            Number of allocations: 4
                            Number of deallocations: 0

                            If I add a definition of new[] I get:

                            Number of allocations: 6
                            Number of deallocations: 0
                            in reply to: Overload new and delete #56077
                            diana
                            Participant
                                Up
                                0
                                Down
                                ::

                                For instance when I execute overloadNewAndDelete incluing myNew.hpp (modified with the addition of the definition of operator new[]) I get the output:
                                Number of allocations: 6

                                Number of deallocations: 0

                                So the operator delete defined on myNew.hpp is not called.

                                Similarly when I include each one of myNew2.hpp, myNew3.hpp, myNew4.hpp the operator delete defined on the header is not called.

                                It’s as if the usual operator delete is called instead.

                                in reply to: Overload new and delete #55220
                                diana
                                Participant
                                    Up
                                    0
                                    Down
                                    ::

                                    Update: The two calls to the overriding new that I am missing are the calls to new []. I added a definition for new [] in myNew.hpp and now I see those calls and the count is 6. The solution with the macro does override new and I get the output corresponding to 6 calls to the overriding new. With all the myNew header options the overriding delete is not called.

                                    in reply to: Overusing auto #9977
                                    diana
                                    Participant
                                        Up
                                        0
                                        Down
                                        ::

                                        I see the point of good names being what makes programs more readable. I wasn’t aware of the guideline, thanks for the pointer!

                                        in reply to: Time duration #9812
                                        diana
                                        Participant
                                            Up
                                            0
                                            Down
                                            ::

                                            Got it so we should cast to the duration we want or use the duration returned by time_since_epoch to initialize a duration that has the period that we want. Thanks for the detailed response!

                                            BTW I won’t be able to make it to today’s Q&A. I’ll see you next week

                                            in reply to: Principles of C++ #9169
                                            diana
                                            Participant
                                                Up
                                                0
                                                Down
                                                ::

                                                Sounds good! Thanks Rainer

                                              Viewing 11 posts - 31 through 41 (of 41 total)