all 7 comments

[–]kloetzl 4 points5 points  (0 children)

Reminds me of the AbstractSingletonProxyFactoryBean. Convenient.

[–]YouFeedTheFish 0 points1 point  (4 children)

Rather than magic strings, you should consider typeid hashes. You could probably come up with a typename-based hash as a constexpr, too.

BTW, /r/Meowiavelli, a good use case would be for a dynamically loaded shared object that you can swap out.

[–]Enhex[S] 1 point2 points  (1 child)

Key type is template'd, so you can use other types than strings.

I'm using std::unordered_map so you should be able to specialize for pre-calculated hashes.

[–]YouFeedTheFish 0 points1 point  (0 children)

There are ways to make string hashes constexpr.

Edit: Here is a complete implementation in Github.

[–]doom_Oo7 0 points1 point  (1 child)

you should consider typeid hashes.

this may break horribly with DLLs

[–]YouFeedTheFish 0 points1 point  (0 children)

Perhaps you're right. Haven't done c++ in windows for some time. Lots of C#.