In this post, we will see how to resolve decltype evaluating the wrong type from an expression list Question: while experimenting with the answer from This post, ended up with the following piece of code: which yields: Here, d comes ...
In this post, we will see how to resolve Is there a way to remove reference, cv qualifiers, and pointerness of a type to make it plain? Question: Take the following code: I would want the domain of passFoo to ...
Question: Compilers agree, that the below X and Y are default-constructible, but not trivially (demo). Why are they not trivial? According to cppreference.com (see is_trivially_constructible) a non-trivial operation must have been called during default-construction. Which one is that? Answer: https://en.cppreference.com/w/cpp/language/default_constructor#Trivial_default_constructor ...
Question: Motivation: In the implementation of P0288 std::move_only_function, I’d like to write a non-allocating special case for conversion from move_only_function<int() noexcept> to move_only_function<int()>: I want to write, like, I wanted to implement that type trait like this: but no vendor ...
Question: I am looking to implement the function is_type_of_v, able to identify the templated instances of type Skill. Please, see the main function in source code below to fully understand the request. It is harder to explain by words than ...
Question: What does these 2 assignments do in this context? class T1 = T class = std::enable_if_t<std::is_same<T1, int>{}> Answer: LowerBound is a member template function declared inside the class template MyClass. It’s similar to a function template but it is ...
Question: I have a CRTP Base class (Bar) which is inherited by a unspecified class. This Derived class may or may not have specific member (internal_foo), and this specific member my or may not have another member (test()). In this ...
Question: I am trying to understand how to use type traits with std::enable_if to “enable” partial specializations of a class. Here is the example code I am attempting to get workingL My goal is to have specific specializations for certain ...
Question: I’m using Catch2 with TEST_CASE blocks from within I sometimes declare local temporary struct for convenience. These struct sometimes needs to be displayed, and to do so Catch2 suggests to implement the << operator with std::ostream. Unfortunately, this becomes ...
Question: For the SFINAE in the hypothetical call operator in this answer I need a type trait that “copies” reference category and const/volatile qualifications from one type to another: I seem to recall some proposed addition to type_traits for this. ...