Forum Replies Created

Viewing 15 posts - 16 through 30 (of 41 total)
  • Author
    Posts
  • in reply to: When to use std::move? #541748
    diana
    Participant
        Up
        0
        Down
        ::

        The clang-tidy rule modernize-pass-by-value suggests to replace the use of const references constructor parameters that are copied into class fields with a pass by value that is then moved.

        in reply to: Industries and projects #482091
        diana
        Participant
            Up
            0
            Down
            ::

            Thank you all for your posts! Very interesting.

            I work on the timing model of FPGAs. An FPGA is a device that has an undefined function at the time of manufacture, it is programmed on the field. A large component of the product is the software that is used to program the device and verify that it will function as expected. Part of that verification is making sure that data can be reliably transferred from register to register in the FPGA and between registers on the FPGA and other devices on the board, that’s where the timing model for the device comes in.

            I am responsible for part of the data that is consumed by the timing model and I am currently restructuring how  we store, verify and query package parasitics and I am adding new functionality to support new packaging methodologies.

            in reply to: Threads and Mutexes #457275
            diana
            Participant
                Up
                0
                Down
                ::

                Related to Driton’s question #4:

                In all the concurrency examples in weeks 28-30 the key variables (mutexes, condition variables, shared data) were declared global. Are the patterns, idioms or strategies to avoid the global variables?

                in reply to: Ping pong exercise #457273
                diana
                Participant
                    Up
                    2
                    Down
                    ::

                    Thanks Driton! Yes this is one instance where I thought this could happen.

                    The part that I was missing is that this doesn’t result in a deadlock because as you say condVar1 releases the mutex, goes to sleep and waits for the notification. I agree one thread could acquire the lock at most twice in a row since the second time around the wait call fails and the thread is blocked until the other thread returns the ball.

                    It could happen multiple times I think, just each time at most twice in a row, for instance if for some reason the call to lock in the last row of the table below (vertical axis is time) gets delayed and t1 has a chance to acquire the lock again before t2 gets a chance to do so. Ultimately the ping pong functionality remains the same with the two threads taking turns in changing the value of the variable.

                    t2(set_false) t1(set_true)
                    lock
                    wait success
                    set variable to true
                    notify
                    lock
                    wait fail
                    unlock
                    lock
                    wait success
                    set variable to false
                    notify
                    wait success
                    lock
                    set variable to true
                    lock

                     

                    in reply to: Antonella Ritorto #389873
                    diana
                    Participant
                        Up
                        0
                        Down
                        ::

                        Welcome Antonella! I am also a Math PhD. I did one postdoc and then moved to industry :) I am from Colombia.

                        in reply to: Replacing the buffer exercise #210696
                        diana
                        Participant
                            Up
                            0
                            Down
                            ::

                            Thanks Rainer. I thought overflow only got called when the sink is exhausted like in the example in the page for std::streambuf::overflow.

                            But I see from your comment that in this case overflow gets called in each of the lines log << … in main

                            I see in cppreference here that the description of std::streambuf::overflow is that it writes characters to the associated output sequence from the put area, so this is in line with your example. In the example in the std::streambuf::overflow page, why does overflow only get called when we exhaust the space in the array that is being used as the sink?

                            in reply to: Memory used by STL containers #106810
                            diana
                            Participant
                                Up
                                0
                                Down
                                ::

                                Does not generalizable mean compiler-dependent and/or architecture-dependent?

                                I was asking the question about size because SL.Con.2 says: “Even when other containers seem more suited, such as map for O(log N) lookup performance or a list for efficient insertion in the middle, a vector will usually still perform better for containers up to a few KB in size.”

                                So I guess the few KB in size is referring to the size of the vector, which we can determine.

                                in reply to: Memory used by STL containers #106649
                                diana
                                Participant
                                    Up
                                    0
                                    Down
                                    ::

                                    Thanks Rainer. I see the answer for std::vector in the post. What about an associative container such as std::unordered_map?

                                    in reply to: Memory used by STL containers #105192
                                    diana
                                    Participant
                                        Up
                                        0
                                        Down
                                        ::

                                        For the advantage about the contiguous layout I see now that the section “Memory predictability” in the  modernes post has an experiment that elaborates on what cache-friendly means.

                                        in reply to: inline in template variable definition #88363
                                        diana
                                        Participant
                                            Up
                                            0
                                            Down
                                            ::

                                            In the example above, why do we care about external linkage if we are using the is_arithmetic_v template variable in the same source file?

                                            Could you elaborate under which circumstances the absence of inline would result in undefined behavior?

                                            My understanding is that:

                                            1. inline means that we allow multiple definitions
                                            2. for an inline variable or inline function, a definition is required in every translation unit that uses it (from Bob Steagall’s The structure of a program in Back to Basics)

                                            In the example above, if we wanted to use is_arithmetic_v in two .cpp files couldn’t we just define is_arithmetic_v in a header file as:

                                            constexpr bool is_arithmetic_v = is_arithmetic<T>::value;

                                            and include the header file in the two .cpp files?

                                            It is not clear to me what is the value of the keyword inline. So there must be something I am not understanding :)

                                            in reply to: Opening external links on a different tab #85851
                                            diana
                                            Participant
                                                Up
                                                0
                                                Down
                                                ::

                                                Thanks Driton! I’ll use the setting you describe for links on my forum posts, didn’t know it was an option.

                                                It would be nice if that was the default behavior on the links in the further info and resources sections.

                                                in reply to: Forum post not listed #85046
                                                diana
                                                Participant
                                                    Up
                                                    0
                                                    Down
                                                    ::

                                                    And indeed I saw my post above right away, no pending moderation message. I posted the message above and this message from an incognito window where I logged in to modernes. I wonder if somehow in my other window where I posted the has function topic I was not logged in but still looked as if I was logged in. I could see all the lessons, the resources page and the forum.

                                                    in reply to: Inheriting from bank account #80348
                                                    diana
                                                    Participant
                                                        Up
                                                        0
                                                        Down
                                                        ::

                                                        Do you mean Account::withdraw(amt)?

                                                        in reply to: Calls to delete in operatorOverloadingAssignment.cpp #69265
                                                        diana
                                                        Participant
                                                            Up
                                                            0
                                                            Down
                                                            ::

                                                            Thank you both! Sorry it was too late last night and didn’t realize that the call to get info was of course before account went out of scope.

                                                            in reply to: cpp stories example #67950
                                                            diana
                                                            Participant
                                                                Up
                                                                0
                                                                Down
                                                                ::

                                                                On the slide about constexpr member functions, it says that they can only be executed by constexpr instances but the code below compiles.  Is this a typo on the slide or am I misunderstanding something? The compiler does complain about the instance being non-constexpr if I declare result to be constexpr.

                                                                 

                                                                #include <iostream>
                                                                
                                                                class MyClass{
                                                                    public:
                                                                        constexpr double interest(double k) const {
                                                                            return k * amount;
                                                                        }
                                                                        void show() const {
                                                                            std::cout << amount << std::endl;
                                                                        }
                                                                    private:
                                                                        int amount{20};
                                                                };
                                                                
                                                                int main(){
                                                                    MyClass nonConstInstance;
                                                                    double result = nonConstInstance.interest(0.10);
                                                                    nonConstInstance.show();
                                                                };
                                                                
                                                              Viewing 15 posts - 16 through 30 (of 41 total)