What is the typical usage of boost any library?

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

    boost::any will happily store ints and floats, types that clearly have no base classes. A real-life example where you can use it is a virtual machine for a high-level interpreted language. Your "function" objects will need an array of arguments. This can easily be implemented with a std::list behind the scenes.

提交回复
热议问题