What is the typical usage of boost any library?

前端 未结 5 1208
暗喜
暗喜 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:15

    Why the same functionality couldn't be achieved by having some generic type in the root of object's hierarchy and creating containers with that base type ?

    That calls an object hierarchy -- a construct you are injecting in artificially in to the design for solving a peripheral problem. Further, such a construct is easy to get wrong and a wrong implementation can wreak havoc. Boost.Any is a community reviewed safe, well-tested alternative.

    Could you please give me some real life examples ?

    TinyJSON uses boost.Any.

    What are the advantages of using boost.any library ?

    I refer the introductory documentation.

提交回复
热议问题