Lines Matching defs:Any

1 //===- Any.h - Generic type erased holder of any type -----------*- C++ -*-===//
9 // This file provides Any, a non-template class modeled in the spirit of
26 class Any {
54 Any() = default;
56 Any(const Any &Other)
59 // When T is Any or T is not copy-constructible we need to explicitly disable
66 llvm::negation<std::is_same<typename std::decay<T>::type, Any>>,
67 // We also disable this overload when an `Any` object can be
74 // going ahead and adopting it to work-around usage of `Any` with
75 // types that need to be implicitly convertible from an `Any`.
76 llvm::negation<std::is_convertible<Any, typename std::decay<T>::type>>,
79 Any(T &&Value) {
84 Any(Any &&Other) : Storage(std::move(Other.Storage)) {}
86 Any &swap(Any &Other) {
91 Any &operator=(Any Other) {
101 template <class T> friend T any_cast(const Any &Value);
102 template <class T> friend T any_cast(Any &Value);
103 template <class T> friend T any_cast(Any &&Value);
104 template <class T> friend const T *any_cast(const Any *Value);
105 template <class T> friend T *any_cast(Any *Value);
106 template <typename T> friend bool any_isa(const Any &Value);
111 template <typename T> const char Any::TypeId<T>::Id = 0;
114 template <typename T> bool any_isa(const Any &Value) {
119 return Value.Storage->id() == &Any::TypeId<U>::Id;
122 template <class T> T any_cast(const Any &Value) {
128 template <class T> T any_cast(Any &Value) {
134 template <class T> T any_cast(Any &&Value) {
140 template <class T> const T *any_cast(const Any *Value) {
146 return &static_cast<Any::StorageImpl<U> &>(*Value->Storage).Value;
149 template <class T> T *any_cast(Any *Value) {
154 return &static_cast<Any::StorageImpl<U> &>(*Value->Storage).Value;