Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Mapping Types to Values (in C++) (gpfault.net)
1 point by nice_byte on Jan 2, 2017 | hide | past | favorite | 3 comments


I only skimmed the article but it seems this requires "registration" for each type and does not support template types.

What I would love to see it a completely generic type-to-value map ToValue<T> for ANY T, possibly template types, and without any sort of registration required. If the results are integers or otherwise ordered, they could then be used for compile-time ordered data structures like RB trees or heaps, for the implementation of some metaprogramming concepts.

Granted I believe that is impossible in plain C++.


No registration required: http://cpp.sh/4zlbc


I was implying a compile-time solution, i.e. where the result of the mapping is constexpr.

On second though, maybe it can be done at compile time, with this: http://b.atch.se/posts/constexpr-counter/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: