Forum Replies Created
-
AuthorPosts
-
::
Hi jleko,
initB() is called for t1( 10 ) because member variable std::string b has a default value (i.e., the return value of function initB() ).
In this case you provide the value only for member variable int a (i.e., 10), so no need to assign its default value (i.e., the return value of function initA() ).
But for member variable std::string b value is provided, thus compiler sets its default value.You can have a look here: https://cppinsights.io/s/3a7243e2
Specially at lines: 20-22 and 26-28 where the Ctors are declared.Best Regards,
Driton::Hi Tobias,
thank you for your comments.
You are right, I could specialize the template functions outside the class definition and it would look like this: https://godbolt.org/z/fxqYjzv57
I am used to complete the template stuff within the class and the header file of course.
::Hi Tobias,
thank you for your hint.It seems that it is an error/bug by IDE Visual Studio 2022 because I can compile and even run the application.
The warning messages show also the correct padding Bytes added at the end of the variables.But the static_assert method remains red underlined and if you hover it, it shows the error message.
But, as I said, I can run the application and it shows the correct sizes:sizeof( l ): 12
sizeof( l2 ): 816. June 2022 at 09:47 in reply to: Extend bigArray exercise by calling push_back() and emplace_back() #11762::But let say I need the whole vector at run-time, with all of its elements, even if they are more than thousand (maybe a bad design but I need it).
Let assume that vector occupies of 1kB memory.- Does this mean that the executable file has a larger size for 1kB, due to this vector?
- Theoritically, if we need 10’000 such std::vectors (I know, it is bad design), does it mean that the executable file is 10’000 times larger?
-
AuthorPosts