-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.cpp
52 lines (42 loc) · 1.48 KB
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// ==========================================================================
// Test Code
// ==========================================================================
#include <iostream>
#include "smart_pointer_type_trait.hpp"
template < typename Ty >
struct Sptr : std::shared_ptr< Ty >
{
Sptr( const Ty& val ) : std::shared_ptr< Ty >( new Ty{ val } ) {}
};
template < typename Ty >
struct Uptr : std::unique_ptr< Ty >
{
Uptr( const Ty& val ) : std::unique_ptr< Ty >( new Ty{ val } ) {}
};
int main()
{
auto check = []( auto&& target )
{
std::cout << typeid( target ).name() << '\n';
std::cout << "is_shared_ptr: " << woon2::is_shared_ptr_v< decltype( target ) > << '\n';
std::cout << "is_unique_ptr: " << woon2::is_unique_ptr_v< decltype( target ) > << '\n';
std::cout << "is_smart_ptr: " << woon2::is_smart_ptr_v< decltype( target ) > << '\n';
std::cout << "is_shared_ptr_soft: " << woon2::is_shared_ptr_soft_v< decltype( target ) > << '\n';
std::cout << "is_unique_ptr_soft: " << woon2::is_unique_ptr_soft_v< decltype( target ) > << '\n';
std::cout << "is_smart_ptr_soft: " << woon2::is_smart_ptr_soft_v< decltype( target ) > << '\n';
std::cout << "is_pointable: " << woon2::is_pointable_v< decltype( target ) > << '\n';
std::cout << "\n\n\n";
};
const auto a = std::make_unique< int >( 3 );
check( a );
Uptr< int > b{ 2 };
check( b );
auto c = std::make_shared< int >( 4 );
check( c );
Sptr< int > d{ 5 };
check( d );
int e = 8;
check( e );
int* f = &e;
check( f );
}