What is the typical usage of boost any library?

前端 未结 5 1195
暗喜
暗喜 2020-12-30 00:44

What are the advantages of using boost.any library ? Could you please give me some real life examples ? Why the same functionality couldn\'t be achieved by having some gener

5条回答
  •  粉色の甜心
    2020-12-30 01:32

    We've used it in a property map, (std::map), to store a lot of things dynamically in a simple, flat dataspace.

    Mostly we either stored smart-ptr-to-scriptable-objects or strings, but some entries where other types (floats, vec3f, matrices, and other non-standard objects).

    It works pretty well for adding more dynamic capabilities to c++, or wherever you want some type-erasure to just add any type of data to an object.

提交回复
热议问题