YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
any.cpp
浏览该文件的文档.
1 /*
2  Copyright by FrankHB 2012 - 2013.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
28 #include "ystdex/any.h"
29 
30 namespace ystdex
31 {
32 
33 any::any(const any& a)
34  : any()
35 {
36  if(a)
37  {
38  manager = a.manager,
40  }
41 }
43 {
44  if(manager)
46 }
47 
48 void*
50 {
51  if(manager)
52  {
54 
56  return t.access<void*>();
57  }
58  return nullptr;
59 }
60 
63 {
64  if(manager)
65  {
67 
69  return t.access<any_ops::holder*>();
70  }
71  return nullptr;
72 }
73 
74 void
76 {
77  if(manager)
78  {
80  manager = nullptr;
81  }
82 }
83 
84 void
86 {
87  std::swap(storage, a.storage),
88  std::swap(manager, a.manager);
89 }
90 
91 const std::type_info&
93 {
94  if(manager)
95  {
97 
99  return *t.access<const std::type_info*>();
100  }
101  return typeid(void);
102 }
103 
104 } // namespace ystdex;
105