Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
hogliux
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
6 ms
·
1.
▲
by
hogliux
1y ago
Long-time happy Wise business customer here (since before the name change). While generally great, their KYC flow needs serious attention. Received four document request emails simultaneously, mostly identical but with different links. In o
2.
▲
by
hogliux
6y ago
IMHO SOUL is a game changer in audio just like OpenGL/Direct3D/etc. was a game changer in the graphics world. Think of all of the graphics technologies that were enabled by OpenGL/Direct3D/... and consider the equivalent
3.
▲
by
hogliux
8y ago
Hmmm, I'm not sure I understand. You can't really mark `static static_map<>::Value& get()` constexpr because it returns a value which is only known at run-time - again the value is a run-time value, only the lookup (wher
4.
▲
by
hogliux
8y ago
Because with a constexpr declaration everything will be constexpr, i.e. you couldn't modify the values at run-time. The idea here is that finding the storage of the value is done at compile-time, but the values themselves are run-time
5.
▲
by
hogliux
8y ago
I'm looking forward to C++-20 when this is not needed anymore :-) - it will support string literals as non-type template parameters.
6.
▲
by
hogliux
8y ago
Both your approach and the `semi::static_map` will generate the same type of load instruction. In both cases, the compiler knows the offset of the values in memory at compile-time. The number of symbols is not really important here.
7.
▲
by
hogliux
8y ago
Yes, that's a nice approach. However, this approach requires you to list all your keys in advance (in the enum). The `semi::static_map` does not require this.This is especially useful if you are writing library code: imagine you are pr
8.
▲
by
hogliux
8y ago
Yup. The frozen map cannot be updated once it is initialized: <<Once initialized, the containers cannot be updated, and in exchange, lookups are faster. And initialization is free when constexpr is used :-).>>
9.
▲
by
hogliux
8y ago
Thanks, I'll have a look at this!
10.
▲
by
hogliux
8y ago
Yes with the optional run-time lookup there is an extra two machine instructions (a cmp and jne) needed to check if this is the first time accessing the value. It is exactly as fast as a global variable if you don't need the optional r
11.
▲
by
hogliux
8y ago
Yes, in a way you are right: the compiler really does boil it down to global variables. However, `semi::static_map` gives you some additional features, which may be useful for a lot of situations 1) `semi::static_map` gives you the optional
12.
▲
C++: Associative map containers with compile-time lookup
(github.com)
155 points
by
hogliux
8y ago
|
42 comments