There are very many very bad C++ books out there. And we are not talking about bad
style, but things like sporting
glaringly obvious factual errors and
promoting abysmally bad programming styles.
auto
#include <iostream>
#include <string_view>
int main()
{
constexpr auto i = 0; // yes, auto, not int
using namespace std::string_view_literals;
const auto hello = "Hello, world!\n"sv;
std::cout << i << '\n' << hello;
}
|
|
|
|
int main()
{
auto i = 0;
auto j = ++i + i++;
return j++ + ++j;
}
|
|
|
|
#include <limits>
int main()
{
auto i = std::numeric_limits<int>::max();
return --i;
}
|
|
C
template <template <typename...> typename C, InputIterator I, Sentinel<I> S>
auto insertion_sort(I first, S last)
{
auto c = C<value_type_t<I>>{};
for (; first != last; ++first)
c.emplace(ranges::find_if(c, [&first](const auto& x) { return x < *first; }, *first);
return c;
}
std::forward_list
(singly linked-list)std::list
(doubly-linked list)std::deque
std::multiset
std::vector