SharedPtr define in namespace
ptbremer opened this issue · 2 comments
ptbremer commented
In the latest master we use
#define SharedPtr std::shared_ptr
But in the downstream code I usually try to avoid a
using namespace Visus;
to avoid polluting my namespace
Instead, I think the more correct usage (I think) is
Visus::SharedPtr pFoo;
But this now lead to an error on my system.
error: no member named 'std' in namespace 'Visus'; did you mean simply 'std'?
The reason is that we are using a #define rather than a typedef which means that my statement get expanded into
Visus::std::SharedPtr pFoo;
which does not compile.
I propose to simply switch to a typedef in Kernel.h, i.e.
typedef SharedPtr std::shared_ptr;
which should fix this
scrgiorgio commented
it's not possible to use a typedef because it's a template class (i.e. a
type does not exists until fully specified using <>).
But fortunately we can use C++11 alias templates (already committed to
GitHub):
#if SWIG
#define SharedPtr std::shared_ptr
#define UniquePtr std::unique_ptr
#else
*//*https://en.cppreference.com/w/cpp/language/type_alias
*template*<*class* T>
*using* SharedPtr = std::shared_ptr<T>;
*template*<*class* T>
*using* UniquePtr = std::unique_ptr<T>;
#endif
Timo, does it solve the problem?
…On Mon, Mar 25, 2019 at 11:31 PM Peer-Timo Bremer ***@***.***> wrote:
In the latest master we use
#define SharedPtr std::shared_ptr
But in the downstream code I usually try to avoid a
using namespace Visus;
to avoid polluting my namespace
Instead, I think the more correct usage is
Visus::SharedPtr pFoo;
But this now lead to an error on my system.
error: no member named 'std' in namespace 'Visus'; did you mean simply
'std'?
The reason is that we are using a #define rather than a typedef which
means that my statement get expanded into
Visus::std::SharedPtr pFoo;
which does not compile.
I propose to simply switch to a typedef in Kernel.h, i.e.
typedef SharedPtr std::shared_ptr;
which should fix this
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#61>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABM8vx6RfP8uqA6Fj3Rle2MWyf110eLfks5vaU4ogaJpZM4cJr8e>
.
ptbremer commented
Yes this compiles