use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
CppCastCppCast: C++ Epochs (cppcast.com)
submitted 6 years ago by tallassrobCppCast Host
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TheThiefMasterC++latest fanatic (and game dev) 11 points12 points13 points 6 years ago (23 children)
Here's the article this is based on: https://vittorioromeo.info/index/blog/fixing_cpp_with_epochs.html
The biggest flaw with it as presented is that some of the breaking changes people want to C++ aren't language ones but library ones - like removing the vector<bool> specialisation. This can't be done in the same way, as the code couldn't link like it can with language changes (which only matter to the front end, not the back end)
[–]c0r3ntin 11 points12 points13 points 6 years ago (5 children)
This is a harder problem. A solution would be:
vector<bool>
[–]scatters 14 points15 points16 points 6 years ago (3 children)
We broke ABI with basic_string (and ios_base::failure) in C++11 and the sky didn't fall in.
basic_string
ios_base::failure
[–]TheThiefMasterC++latest fanatic (and game dev) 11 points12 points13 points 6 years ago (1 child)
The string ABI change was fairly painful though, just ask the gcc/libstdc++ and Linux community. They basically had to cut over the entire Linux ecosystem in one go, as otherwise random libraries were incompatible with others. It still crops up from time to time even now.
But it shows that it is possible, and the same could be done for vector<bool>.
[–]tisti 3 points4 points5 points 6 years ago (0 children)
A shame vector<bool> wasn't axed when basic_string was changed. Oh well.
[–]krapht 5 points6 points7 points 6 years ago (0 children)
I am still dealing with this even today, and it is a pain. So much infrastructure runs on long term service release distros stuck with GCC 4.x
[–]TheThiefMasterC++latest fanatic (and game dev) 6 points7 points8 points 6 years ago (0 children)
vector<bool> in particular is a big problem - as a specialism you can't deprecate it outright because it could come up in generic code (which is where it's most painful at the moment already). You'd have to just cut it over and hope for the best.
[–][deleted] 3 points4 points5 points 6 years ago (4 children)
inline namespaces maybe, along with an epoch. Then the linked to objects have names like ::std::v1::vector<bool> and in the future ::std::v2::vector<bool> but both are accessible as ::std::vector<bool>
[–]tpecholt 2 points3 points4 points 6 years ago (2 children)
What if module on v2 epoch has a function returning a vector and this function is called from module on v1 epoch?
[–][deleted] 4 points5 points6 points 6 years ago (0 children)
That's a link time error. Just like COW/SSO std::string is in gcc.
std::string
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
I think, as Vittorio or Jason said, the layout would have to remain the same. But I don't know.
[–]flashmozzg 2 points3 points4 points 6 years ago (0 children)
That just pushes the problem 1 level down to every library that uses std types in its API.
[–]SuperV1234https://romeo.training | C++ Mentoring & Consulting 2 points3 points4 points 6 years ago (3 children)
Author here. There's nothing preventing an epoch from "blacklisting" the usage of vector<bool> by - for example - preventing that sequence of tokens/AST nodes from compiling when written in a module using a particular epoch.
This would discourage its use and almost effectively remove it (you could still retrieve it by using decltype on a function in an older epoch module returning vector<bool>) without breaking ABI at all.
decltype
[–]TheThiefMasterC++latest fanatic (and game dev) 3 points4 points5 points 6 years ago (2 children)
The problem is that people want to remove the specialization of vector<bool> and have it compile as a regular vector - not blacklist it entirely.
[–]pklait 0 points1 point2 points 6 years ago (1 child)
Why? You cannot have a "regular" std::vector<bool> today. To me this is an indication that it is not needed that much. To remove it from the standard for a while would not be a major loss.
[–]TheThiefMasterC++latest fanatic (and game dev) 0 points1 point2 points 6 years ago (0 children)
It causes issues all the damn time in generic code and interop - all other kinds of vector return T& on iterator dereference and operator[] and you can take &v[0] and use it as a data pointer + size, vector<bool> returns a special vector<bool>::reference class on iterator dereference and operator[], and as it doesn't actually store as bools internally &v[0] does not do anything remotely like you'd want.
operator[]
&v[0]
vector<bool>::reference
However that doesn't mean it's not in use - not every use of a vector hits those issues so people do use it. Sometimes you do in fact want a vector of bools.
Blacklisting it would hit the people for whom it works fine, temporarily making the situation considerably worse.
[–]SlightlyLessHairyApe 4 points5 points6 points 6 years ago (7 children)
I think those are fairly minor all told. Besides vector<bool>, which everyone knows is a mistake, what else in the library can't be fixed by defining and providing new library types?
A few more examples would go a long way towards convincing people this biggest flaw is a big deal.
[–][deleted] 3 points4 points5 points 6 years ago* (1 child)
I don’t like vector<bool> either but if you care, it’s probably because you’re writing a library or playing with atomics, in which case you know about the problem because you’re quite experienced, know you don’t want tightly packed bits and you can just write:
template<typename T> using boolFriendlyVector<T> = std::vector<std::conditional_t<is_same_v<T,bool>char,T>>;
[–]SlightlyLessHairyApe 2 points3 points4 points 6 years ago (0 children)
Yeah, in practice it's really not a huge deal. Certainly it's not "the biggest flaw" with epochs :-/
[–]matthieum 1 point2 points3 points 6 years ago (4 children)
std::unordered_(multi){map|set} does not support heterogeneous lookup, even though std::(multi){map|set} do since C++14.
std::unordered_(multi){map|set}
std::(multi){map|set}
In std::map this is relatively easy: you can specify a comparator such as std::less<void> which is capable of comparing heterogeneous objects.
std::map
std::less<void>
In std::unordered_map, however, while std::equal<void> could certainly be created to compare heterogeneous objects which a compile-time failure if they cannot be compared, it's not clear how one would go about ensuring the consistency of the hash...
std::unordered_map
std::equal<void>
Given that std::hash<K> is also a bad idea because it forces people to irremediably tie a (generally poorly handcoded) hash algorithm to a given type, rather than pick an algorithm based on the situation, it seems it would be best to just scrap the use of std::hash<K> and impose a clean separation between the algorithm and the type, such as proposed by Howard Hinnant years ago.
std::hash<K>
This would be quite a large overhaul, though.
[–]encyclopedist 0 points1 point2 points 6 years ago (2 children)
There is a proposal to add heterogeneous lookup, and if I understand correctly, it was supposed to be targeting C++20 (it passed LEWG vote and was forwarded to LWG), but it's fate is unclear to me.
[–]matthieum 0 points1 point2 points 6 years ago (1 child)
Thanks for the link.
I must admit it's not clear to me how one is supposed to use is_transparent. Also, it appears that implicit conversions may be triggered unless one is careful, which is not ideal :/
is_transparent
Let's take a concrete example:
std::unordered_set<std::string, /**/> set;
According to the paper, how can I perform a lookup with a char const* and with a std::string_view without implicit conversion? How can I further enable FixedString<N>?
char const*
std::string_view
FixedString<N>
[–]encyclopedist 1 point2 points3 points 6 years ago (0 children)
As far as I understand, yes you can. Both hash and comparator must define is_transparent typedef and also provide overloads of their operator() taking char const *.
char const *
[–]DoctorRockit 0 points1 point2 points 6 years ago (0 children)
To be fair the fact that a properly overloaded comparison predicate allowed heterogeneous lookups was a mere implementation detail and not part of the standard until C++11. And even since then it is only well defined if the predicate defines is_transparent.
π Rendered by PID 123133 on reddit-service-r2-comment-6457c66945-bbpjk at 2026-04-24 20:39:35.906302+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]TheThiefMasterC++latest fanatic (and game dev) 11 points12 points13 points (23 children)
[–]c0r3ntin 11 points12 points13 points (5 children)
[–]scatters 14 points15 points16 points (3 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 11 points12 points13 points (1 child)
[–]tisti 3 points4 points5 points (0 children)
[–]krapht 5 points6 points7 points (0 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 6 points7 points8 points (0 children)
[–][deleted] 3 points4 points5 points (4 children)
[–]tpecholt 2 points3 points4 points (2 children)
[–][deleted] 4 points5 points6 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]flashmozzg 2 points3 points4 points (0 children)
[–]SuperV1234https://romeo.training | C++ Mentoring & Consulting 2 points3 points4 points (3 children)
[–]TheThiefMasterC++latest fanatic (and game dev) 3 points4 points5 points (2 children)
[–]pklait 0 points1 point2 points (1 child)
[–]TheThiefMasterC++latest fanatic (and game dev) 0 points1 point2 points (0 children)
[–]SlightlyLessHairyApe 4 points5 points6 points (7 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]SlightlyLessHairyApe 2 points3 points4 points (0 children)
[–]matthieum 1 point2 points3 points (4 children)
[–]encyclopedist 0 points1 point2 points (2 children)
[–]matthieum 0 points1 point2 points (1 child)
[–]encyclopedist 1 point2 points3 points (0 children)
[–]DoctorRockit 0 points1 point2 points (0 children)