6

Below is excerpted from gsl.h of Microsoft's gsl library (https://github.com/microsoft/gsl):

namespace gsl
{
    //
    // GSL.owner: ownership pointers 
    //
    using std::unique_ptr;
    using std::shared_ptr;

    template<class T>
    using owner = T;
    ...
};

I cannot understand what the following alias template means:

template<class T>
using owner = T;

Any explanations?

Severin Pappadeux
  • 18,636
  • 3
  • 38
  • 64
xmllmx
  • 39,765
  • 26
  • 162
  • 323
  • 1
    Possible duplicate of [What is the difference between 'typedef' and 'using' in C++11?](http://stackoverflow.com/questions/10747810/what-is-the-difference-between-typedef-and-using-in-c11) – Qix - MONICA WAS MISTREATED Jul 19 '16 at 04:01

2 Answers2

7

It means that for every T, owner<T> is an alias for T.

Brian Bi
  • 111,498
  • 10
  • 176
  • 312
2

It can be used as annotation to show which pointers are 'owner' ie:

Example of non owning raw pointer

template<typename T>
class X2 {
    // ...
public:
    owner<T*> p;  // OK: p is owning
    T* q;         // OK: q is not owning
};
arenard
  • 652
  • 6
  • 12