Let's say I have a class A which specifies conversion to int

```
struct A {
  int val = 42;
  operator int() const {
    return val;
}

```

so I can use it like this:

```
A a;
int a_int = a;

```

But what if I want to use shared pointer to the class:

```
auto a_ptr = std::shared_ptr<A>(new A);
int a_int = a_ptr; // ???

```

Just like the variable with type A was implicitly converted to int I want to do the same with a smart pointer.
How can I achieve that?

**UPDATE**

I'm sorry maybe I asked wrong way.
The real deal is a little bit more complicated.
I use QVariant to hold std::shared\_ptr.
for now I have a helper function to do that:

```
QVariant & operator<< (QVariant& v, const std::shared_ptr<A> & aPtr);

```

When I need to place my pointer to QVariant I do this:

```
QVariant variant = QVariant() << a_ptr;

```

But I want to do it automatically, something like this:

```
QVariant variant = a_ptr;

```