Differences between std::is_convertible and std::convertible_to (in practice)?

std::is_convertible<From, To> (the type trait) checks is type From is implicitly convertible to type To. std::convertible_to<From, To> (the concept) checks that From is both implicitly and explicitly convertible to To. It’s rare that this is not the case, such types are ridiculous, but it’s nice in generic code to just not have to worry about … Read more

How do I build gcc with C++ concepts (“concepts lite”) support?

As of Fri, 7 Aug 2015 01:44:49 -0400 (05:44 +0000) concepts support has been merged into gcc’s trunk. Using a build from after that point, you can enable concepts support with the -std=c++1z flag. As of gcc 6.1 (27-04-2016), concepts are enabled by -fconcepts as they are unlikely to be included in C++17, so they … Read more

Why does double negation change the value of C++ concept?

Here the concept D is the same as the concept C They are not. Constraints (and concept-ids) are normalized when checked for satisfaction and broken down to atomic constraints. [temp.names] 8 A concept-id is a simple-template-id where the template-name is a concept-name. A concept-id is a prvalue of type bool, and does not name a … Read more

Why is unique_ptr not equality_comparable_with nullptr_t in C++20?

TL;DR: std::equality_comparable_with<T, U> requires that both T and U are convertible to the common reference of T and U. For the case of std::unique_ptr<T> and std::nullptr_t, this requires that std::unique_ptr<T> is copy-constructible, which it is not. Buckle in. This is quite the ride. Consider me nerd-sniped. Why don’t we satisfy the concept? std::equality_comparable_with requires: template … Read more

New iterator requirements

These are not new things, hence the term “legacy”. This is simply how the cppreference site chooses to reconcile the fact that C++20 will have two different things that are both “concepts” called “RandomAccessIterator” (well, until C++20 decided to rename their version random_access_iterator). Pre-C++20, a “concept” was just a set of requirements in the standard … Read more

What are the similarities and differences between C++’s concepts and Rust’s traits?

Disclaimer: I have not yet used concepts, all I know about them was gleaned from the various proposals and cppreference, so take this answer with a grain of salt. Run-Time Polymorphism Rust Traits are used both for Compile-Time Polymorphism and, sometimes, Run-Time Polymorphism; Concepts are only about Compile-Time Polymorphism. Structural vs Nominal. The greatest difference … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)