mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
ref<T>: Add cast operator
This commit is contained in:
parent
ad0dc41899
commit
fd205fb6f8
2 changed files with 8 additions and 15 deletions
|
@ -322,8 +322,8 @@ ref<Store> openStore(bool reserveSpace)
|
|||
}
|
||||
|
||||
return mode == mDaemon
|
||||
? make_ref<Store, RemoteStore>()
|
||||
: make_ref<Store, LocalStore>(reserveSpace);
|
||||
? (ref<Store>) make_ref<RemoteStore>()
|
||||
: (ref<Store>) make_ref<LocalStore>(reserveSpace);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -134,16 +134,18 @@ public:
|
|||
return p;
|
||||
}
|
||||
|
||||
template<typename T2>
|
||||
operator ref<T2> ()
|
||||
{
|
||||
return ref<T2>((std::shared_ptr<T2>) p);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
template<typename T2, typename... Args>
|
||||
friend ref<T2>
|
||||
make_ref(Args&&... args);
|
||||
|
||||
template<typename T2, typename T3, typename... Args>
|
||||
friend ref<T2>
|
||||
make_ref(Args&&... args);
|
||||
|
||||
};
|
||||
|
||||
template<typename T, typename... Args>
|
||||
|
@ -154,13 +156,4 @@ make_ref(Args&&... args)
|
|||
return ref<T>(p);
|
||||
}
|
||||
|
||||
template<typename T, typename T2, typename... Args>
|
||||
inline ref<T>
|
||||
make_ref(Args&&... args)
|
||||
{
|
||||
auto p = std::make_shared<T2>(std::forward<Args>(args)...);
|
||||
return ref<T>(p);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue