Category : typetraits

While compiling HHVM, the code fails due to: /usr/include/c++/10/type_traits:918:52: error: non-constant condition for static assertion 918 | static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), What does __is_complete_or_unbounded actually do/check? The issue occurs while constructing an object whose last member variable is as follows: value_type cell[0] The constructor does not initialize this member, is this the problem? How would I initialize the ..

Read more

Setup I asked a question yesterday about template method overloading and resolving issues using type traits. I received some excellent answers, and they led me to a solution. And that solution led me to more reading. I landed on a page at Fluent CPP — https://www.fluentcpp.com/2018/05/18/make-sfinae-pretty-2-hidden-beauty-sfinae/ that was interesting, and then I listened to the ..

Read more

#include <type_traits> int main() { auto f1 = [](auto&) mutable {}; static_assert(std::is_invocable_v<decltype(f1), int&>); // ok auto const f2 = [](auto&) {}; static_assert(std::is_invocable_v<decltype(f2), int&>); // ok auto const f3 = [](auto&) mutable {}; static_assert(std::is_invocable_v<decltype(f3), int&>); // failed } See demo Why can’t a const mutable lambda take a reference argument? Source: Windows Que..

Read more

std::common_type<T1, …, TN> is a helper template in C++ which can find the common type which all of T1 … TN are implicitly convertible to. According the C++ spec, a user may specialize std::common_type<T1,T2> if certain conditions apply, and: std::common_type<T1, T2>::type and std::common_type<T2, T1>::type must denote the same type. However, common_type<T1, T2> might be a ..

Read more