Class ov::Any

class Any

This class represents an object to work with different types.

Public Functions

Any() = default

Default constructor.

Any(const Any &other)

Сopy constructor.

Parameters

other – other Any object

Any &operator=(const Any &other)

Сopy assignment operator.

Parameters

other – other Any object

Returns

reference to the current object

Any(Any &&other) = default

Default move constructor.

Parameters

other – other Any 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

TAny 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

template<class T>
inline std::enable_if<std::is_convertible<T, std::shared_ptr<RuntimeAttribute>>::value, T>::type &as()

Dynamic cast to specified type

Template Parameters

T – type

Returns

casted object

template<class T>
inline std::enable_if<!std::is_convertible<T, std::shared_ptr<RuntimeAttribute>>::value && !std::is_same<T, std::string>::value && std::is_default_constructible<T>::value && (util::Istreamable<T>::value || util::Readable<T>::value), T>::type &as()

Dynamic cast to specified type

Template Parameters

T – type

Returns

casted object

template<class T>
inline std::enable_if<!std::is_convertible<T, std::shared_ptr<RuntimeAttribute>>::value && !std::is_same<T, std::string>::value && (!std::is_default_constructible<T>::value || (!util::Istreamable<T>::value && !util::Readable<T>::value)), T>::type &as()

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

streamOutput 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

streamOutput 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

Public Static Functions

template<typename T, typename ...Args>
static inline Any make(Args&&... args)

Inplace value construction function.

Template Parameters
  • TAny type

  • Args – pack of paramter types passed to T constructor

Parameters

args – pack of paramters passed to T constructor