Should third-party types be exposed in my C++ library's API

后端 未结 2 764
温柔的废话
温柔的废话 2020-12-18 07:33

I\'m developing a C++ library where user\'s will provide complex inputs, such as matrices and quaternions. I don\'t want to have to reimplement these types so, internally, I

2条回答
  •  佛祖请我去吃肉
    2020-12-18 08:10

    Wrap / encapsulate. Say you want to add some additional feature, such as caching the result of a computation, like the norm of a quaternion, as an implementation change. You can't do that (as easily) if you expose the 3rd party types without forcing your client code to change its call.

提交回复
热议问题