trivial copy constructor and implicity copy construcy)
I cant undrestand, can someone easy explain with example??
Implicit is the ones that generated automatically for you. E.g. you have a struct with data, you will have default/copy/move constructors implicitly generated for you. Trivial means it either does nothing (for default constructor) or can be replaced with memcpy (for copy/move constructors). So, for example, in the case of structs above, if the struct has only ints as members, default/move/copy constructors generated will be trivial. If you have a std::string as a member, the struct won't be able to generate trivial constructors because std::string has user-defined constructors.
So copy constructor is implicity? Cause it creates default by compiler?
Copy constructor can be generated implicitly if you don't provide user-defined one, or if you do = default on copy constructor declaration. But it can be generated only in case all your members can be copied.
I undrestand Thnx🌹
Обсуждают сегодня