28 Ocak 2017 Cumartesi


Açıklaması şöyle. Veriyi void* olarak saklar.
std::any has to be implemented with type-erasure. That's because it can store any type and can't be a template. There is just no other functionality in C++ to achieve this at the moment.

What that means is that std::any will store a type-erased pointer, void* and std::any_cast will convert that pointer to the specified type and that's it.
Small Object Optimization
Bu sınıf small object optimization yöntemini belki uygulayabilir ancak garanti sağlamaz. Açıklaması şöyle.
Implementations should avoid the use of dynamically allocated memory for a small contained object. [ Example: where the object constructed is holding only an int.  — end example ] Such small-object optimization shall only be applied to types T for which is_­nothrow_­move_­constructible_­v<T> is true.
std::any_cast metodu
Bu sınıftaki nesneye erişmek için std::any_cast kullanılır.

Hiç yorum yok:

Yorum Gönder