我希望能够减少代码中的一些视觉噪音,并使用typedef来隐藏shared_ptr
,类似于这样:
typedef boost::shared_ptr<SomeLongClass> SomeLongClassPtr;
所以这样:void foo(const boost::shared_ptr<SomeLongClass>& a,
boost::shared_ptr<SomeLongClass>& b);
变成了这样:
void foo(const SomeLongClassPtr& a, SomeLongClassPtr& b);
另一方面,我担心我会降低代码的明确性。
哪种风格更好呢?