Class ov::Any#
-
class Any#
This class represents an object to work with different types.
Public Functions
-
Any() = default#
Default constructor.
-
Any &operator=(const Any &other)#
Сopy assignment operator.
- Parameters:
other – other Any object
- Returns:
reference to the current object
-
Any &operator=(Any &&other) = default#
Default move assignment operator.
- Parameters:
other – other Any object
- Returns:
reference to the current object
-
~Any()#
Destructor preserves unloading order of implementation object and reference to library.
-
template<typename T, typename std::enable_if<!std::is_same<decay_t<T>, Any>::value && !std::is_abstract<decay_t<T>>::value && !std::is_convertible<decay_t<T>, Base::Ptr>::value, bool>::type = true>
inline Any(T &&value)# Constructor creates any with object.
- Template Parameters:
T – Any type
- Parameters:
value – object
-
Any(const char *str)#
Constructor creates string any from char *.
- Parameters:
str – char array
-
Any(const std::nullptr_t)#
Empty constructor.
-
const std::type_info &type_info() const#
Returns type info
- Returns:
type info
-
bool empty() const#
Checks that any contains a value
- Returns:
false if any contains a value else false
-
template<class T>
inline bool is() const# Check that stored type can be casted to specified type. If internal type supports Base.
- Template Parameters:
T – Type of value
- Returns:
true if type of value is correct. Return false if any is empty
Dynamic cast to specified type
- Template Parameters:
T – type
- Returns:
casted object
Dynamic cast to specified type
- Template Parameters:
T – type
- Returns:
casted object
Dynamic cast to specified type
- Template Parameters:
T – type
- Returns:
casted object
-
template<class T>
inline std::enable_if<std::is_same<T, std::string>::value, T>::type &as()# Dynamic cast to specified type
- Template Parameters:
T – type
- Returns:
casted object
-
template<class T>
inline const T &as() const# Dynamic cast to specified type
- Template Parameters:
T – type
- Returns:
const reference to caster object
-
bool operator==(const Any &other) const#
The comparison operator for the Any.
- Parameters:
other – object to compare
- Returns:
true if objects are equal
-
bool operator==(const std::nullptr_t&) const#
The comparison operator for the Any.
- Parameters:
other – object to compare
- Returns:
true if objects are equal
-
bool operator!=(const Any &other) const#
The comparison operator for the Any.
- Parameters:
other – object to compare
- Returns:
true if objects aren’t equal
-
void print(std::ostream &stream) const#
Prints underlying object to the given output stream. Uses operator<< if it is defined, leaves stream unchanged otherwise. In case of empty any or nullptr stream immediately returns.
- Parameters:
stream – Output stream object will be printed to.
-
void read(std::istream &stream)#
Read into underlying object from the given input stream. Uses operator>> if it is defined, leaves stream unchanged otherwise. In case of empty any or nullptr stream immediately returns.
- Parameters:
stream – Output stream object will be printed to.
-
void *addressof()#
Returns address to internal value if any is not empty and
nullptr
instead.- Returns:
address to internal stored value
-
const void *addressof() const#
Returns address to internal value if any is not empty and
nullptr
instead.- Returns:
address to internal stored value
-
Any() = default#