Perfect Forwarding and move

72 views Asked by At

I have a program where i have a struct with 2 data members

     struct myStruct{
           uint64_t promotionID;
           int32_t amount;
     };

I have to add them to an unordered_map where i had many copy operations. Right now I am searching for perfect forwarding and move, should i learn these to get rid of the copy operations of int32_t and uint64_t? Will that effect to the speed of the program (i don't have any pointer)? Here is how i add to the unordered map which makes a lot of copy operations:

void Customer::AddCustomer
   {
        my_customer_datatype addCustomer;
        addCustomer.promotionID=promotionID;
        addCustomer.amount=amount;
        customerMap->emplace(std::make_pair(customerID,addCustomer));
   }

I will read a lot of data so i need to write an efficient(in terms of speed) program. If you have any advise that i can search in detail to increase speed i will be appreciated. (I also use reserve for unordered map)

0

There are 0 answers