refactor(core): deprecate SPTR, CSPTR & co. macros
Description
TL;DR: We do not need the macros SPTR
, CSPTR
, UPTR
, etc. They pollute the global namespace
and have trivial, clean, replacement.
The following discussion from !926 (merged) should be addressed:
-
@eduhamel started a discussion: (+2 comments) Not a blocking comment. Please feel free to close without answer or resolve in a issue.
I'm wondering if we should not, at some point, remove (or at least deprecate) those ugly macros.
In short, we could do
// core/smart_pointer.hpp #include <memory> namespace sight { template<typename T, typename deleter = std::default_deleter<T>> using uptr = std::unique_ptr<T, deleter>; template<typename T> using sptr = std::shared_ptr<T>; template<typename T> using wptr = std::weak_ptr<const T, deleter>; template<typename T> using csptr = std::shared_ptr<const T>; //etc. } // namespace sight
Note: I know this is 0 added value regarding pure features, thus my note above.
Proposal
- Provide
core/smart_pointer.hpp
, which is similar to above (with the missing types added of course). - Remove the old macros.
- Remove
typedef
s inclass
es added bySIGHT_DECLARE_CLASS
and similar. - If necessary, we may generate/write
data/smart_pointer.hpp
which may look like:
// data/smart_pointer.hpp
#include "core/smart_pointer.hpp"
namespace sight
{
namespace data
{
class Object;
class Image;
// ...
using object_uptr = uptr<Object>;
using object_sptr = sptr<Object>;
using object_csptr = sptr<Object>;
// ...
using image_uptr = uptr<Image>;
using image_sptr = sptr<Image>;
using image_csptr = sptr<Image>;
// ...
} // namespace data
// namespace sight
This is the occasion to remove useless #include
s of data/stuff.hpp
in most headers. With this change, this makes possible to replace (in most places) these large chunks of #include
s by a/a few forward declaration(s) such as in suggested data/smart_pointer.hpp
, which should bring a considerable reduction of compilation time shouldn't be visible in compilation time unfortunately (see this comment), but should at least reduce pollution.
Functional specifications
TBA
Technical specifications
TBA
Test plan
TBA