Anonymous types in C ++

I was wondering if there is any equivalent or way to fake anonymous C # types in C ++. I am using gcc 4.6, so any parts of supported C ++ 0x can be used.

+3
source share
2 answers

If you are looking for a container in which a “bag” of different types can be stored, the closest analogue will be std::tuple.

+5
source

You can fake it with std::map<std::string, boost::any>, but it really is not the same. There is no way to get anything truly like anonymous C # 3+ types in C ++.

Anonymous types are really useful for LINQ anyway, and C ++ doesn't support anything like that either, so it's unlikely that would be useful anyway.

+2
source

Source: https://habr.com/ru/post/1770946/


All Articles