Category : language-lawyer

I am a bit confused about the C++17 standard named requirements regarding iterators; it seems to me that std::map::iterator violates the requirements. From the standard, I gather the following: All container iterators are supposed to satisfy ForwardIterator. For an iterator It satisfying ForwardIterator, std::iterator_traits<It>::reference has to be either value_type& – if It is mutable – ..

Read more

Hi i am reading about expression in C++ and across the statement Statement 0.0 Each expression has some non-reference type The quoted statement is from en.cppreference.com/w/cpp/language/value_category. Check line 2 at the top of the page. Now i took some examples to understand what this means. For example: int i = 100; // this expression has ..

Read more

In real code, constructors can be very complex and so the emplace of a std::optinal can query the status of the optional itself. When this happens it’s usually a bit more convoluted, but here is a (contrived) minimal example: #include <iostream> #include <optional> struct Thing { Thing(); }; std::optional<Thing> othing; Thing::Thing() { std::cout << othing.has_value() ..

Read more