metaprogramming: trait to detect smart-pointers
This commit is contained in:
parent
020940545c
commit
52918b069f
2 changed files with 27 additions and 0 deletions
|
|
@ -319,6 +319,24 @@ namespace meta {
|
|||
|
||||
|
||||
|
||||
/** detect smart pointers */
|
||||
template<typename X>
|
||||
struct is_smart_ptr
|
||||
: std::false_type
|
||||
{ };
|
||||
|
||||
template<typename T>
|
||||
struct is_smart_ptr<std::shared_ptr<T>>
|
||||
: std::true_type
|
||||
{ };
|
||||
|
||||
template <typename T, typename D>
|
||||
struct is_smart_ptr<std::unique_ptr<T,D>>
|
||||
: std::true_type
|
||||
{ };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,15 @@ namespace std { // forward declaration for std::string...
|
|||
class basic_string;
|
||||
|
||||
using string = basic_string<char, char_traits<char>, allocator<char>>;
|
||||
|
||||
|
||||
// forward declarations for common smart ptrs
|
||||
template<typename T>
|
||||
class shared_ptr;
|
||||
|
||||
template <typename T, typename D>
|
||||
class unique_ptr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue