GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • C++Tipsand other shenanigans
  • Tips
  • Articles
  • Updates
  • About
  • Archive
  • Tags
  • Categories
  • RSS
  • Sitemap

This view

  • Original page
  • New address

GeezerVison is showing cpp.tips — Tips — C++ Tips

Showing : Clear filter
01

Are your maps allocating unnecessarily?

By Matthew TaylorOctober 15, 2026

Consider a map with a std::string as the key type, for example mapping an HTTP route to its handler:

1
std::unordered_map<std::string, Handler const*> handlers;

What actually happens when you try to look things up in this map? Let’s say that you want to test it with handlers.find("/api/v2/accounts/positions/summary"). This code will compile and run quite happily, but under the hood this allocates the literal into an entirely new std::string object, hashes it, finds the value, and then throws the temporary string away.

Read more →
02

Can you subscript tuples?

By Matthias WippichSeptember 20, 2026#Clang

In C++ tuples are implemented as library feature rather than as language feature. As a consequence of that, we are syntactically limited by what the language offers.

This means rather than being able to subscript tuples directly, we need to use std::get<N>(tup) instead.

So… if we step a bit outside of the boundaries of the standard, can we subscript instead?

1
auto tup = nonstd::tuple(1, 'c', 3.2);
2
f(tup[0], tup[2]);
Read more →
03

Your compiler complains you're not in template context?

By Matthias WippichSeptember 17, 2026#Clang

This can happen if you attempt to use P1061 pack-introducing structured bindings outside of a template:

1
void f() {
2
// error: pack declaration outside of template
3
auto [...Is] = expr;
4
}

To avoid turning f itself into a template, you can use P1306 expansion statements. Unlike lambda solutions, this does not push another function scope.

Read more →

No entries match this filter.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.