EN VI
Posts (0)
Questions (49)
2024-03-12 16:30:04
You may want to look into the CRTP pattern for this, if I understand your intent correctly. Also, your outline has no way to properly free dynamic memory, you better derive BaseV from a common interfa...
Tags: c++ templates inheritance
2024-03-12 17:30:05
how to define in C++20 a concept to check if a type matches any of the types in a type-list Method 1 You can change the program to as shown below. This is more readable than method 2. template struc...
2024-03-12 20:00:07
Function ranges::fold_left_first returns std::optional rather then int: https://en.cppreference.com/w/cpp/algorithm/ranges/fold_left_first Here's the corrected code: #include #include #include #i...
Tags: c++ fold std-ranges
2024-03-12 22:00:07
When you compile C++ code on a MacBook, especially on one with the M1 or M2 chip which uses the ARM64 architecture, using gcc directly sometimes doesn't automatically link against the C++ standard lib...
2024-03-13 04:30:05
The idiomatic solution is using std::conditional: template class A { B var; };
2024-03-13 11:30:04
If you define a function in a derived class it completely hides any function in the base class with the same name in the derived class's namespace. That means that the add member function in your Lexe...
Tags: c++ inheritance struct
2024-03-13 17:30:06
WaitForMultipleObjects can only wait on a maximum of MAXIMUM_WAIT_OBJECTS (which is 64) handles. As soon as you try to wait on more handles which is the case in your code, the wait fails and therefore...
Tags: c++ multithreading winapi
2024-03-13 21:00:12
Because of how template argument deduction is specified (see: https://en.cppreference.com/w/cpp/language/template_argument_deduction#Conversion_function_template, Implications of conversion function t...
Tags: c++ c++17 clang++
2024-03-13 21:30:06
sort(begin(A), end(A)); sorts the all 1000 elements of the array int A[1000];. This includes uninitialized elements, so the sorting may put garbage values to what is processed and may lead to wrong ou...
Tags: c++
2024-03-13 23:00:05
You won't get a compile time check for your runtime value. You can get Compiletime checks for your constexpr values Runtime checks for runtime values Example: template class A { private: std::a...
Tags: c++ arrays

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login