error: operands to ‘?:’ have different types ‘int’ and ‘Person’
I am trying to have one function, where I can check if the type passed in is of class object or simply a variable datatype. Depending on the condition of this truth, I’d do something with this. However, this does not work as expected.
error: ‘struct Person’ has no member named ‘get_age’; did you mean ‘m_age’?
I am trying to have one function, where I can check if the type passed in is of class object or simply a variable datatype. Depending on the condition of this truth, I’d do something with this. However, this does not work as expected.
Why C++ conditional variables only be used with std::unique_lock?
std::condition_variable
works only with std::unique_lock<std::mutex>
, which allows for maximal efficiency on some platforms. std::condition_variable_any
provides a condition variable that works with any BasicLockable
object, such as std::shared_lock
.
Can C++ conditional variables be used with std::scoped_lock?
std::condition_variable works only with std::unique_lockstd::mutex, which allows for maximal efficiency on some platforms. std::condition_variable_any provides a condition variable that works with any BasicLockable object, such as std::shared_lock.
In constructor ‘ArgumentGuard::ArgumentGuard(int&, const char**)’:
I have this class I just wrote, see below. I am trying to create like a handle utility class
for checking the argc
and argv
from the main in command line.
Code optimization or how to speed up code
Given a number n, print all correct parenthesis sequences of parentheses and square brackets of length n in lexicographical order. You must enter an integer $n$ from 0 to 16 inclusive. The output should be “Print all valid parenthesis sequences of length n parentheses and square brackets in lexicographical order. Each sequence should be printed on a new line”
Incomprehensible operation of the skin and memory
To check how well her students can count, Maria Ivanovna assigns them the same problem every year – for a given natural number ( A ), find the smallest natural number ( N ) such that ( N ) to the power of ( N ) (i.e., ( N ) multiplied by itself ( N ) times) is divisible by ( A ). Each year, only the number ( A ) changes for each student. You have decided to help future generations. To do this, you need to write a program that solves this problem. The input file contains a single integer ( A ) (( 1 leq A leq 10^9 )). Just in case Maria Ivanovna decides to give a large number to challenge someone.
Fold-expression to concatenate string_views
I wanted to have a fold-expressioned function that concatenates string_views. But the code I tried didn’t work. What am I makging wrong ?
Initializing a std::string_view with a C-style string literal
std::string_view objects only have a view over an object such as a std::string, and modifying the value of a string used to initialize a string_view will invalidate it.
Now, if I initialize a string_view with a C-style string literal, as follows :
std::string_view s{ "Hello, world!" };
Is it possible to create constexpr value of std::array inside std::array?
I’m working on optimization of some settings code. This is a large array of predefined values groupped in three nested structures. It is defined as