## virtual_traits ### Synopsis Defined in . ```c++ namespace boost::openmethod { template struct virtual_traits; // not defined template struct virtual_traits<..., Policy> { using virtual_type = ...; static auto peek(const T& arg) -> const ...&; template static auto cast(T& obj) -> ...; template using rebind = ...; // for smart virtual pointers }; } ``` ### Description Specializations of `virtual_traits` provide an interface for `method` and `virtual_ptr` to manipulate virtual arguments. ### Specializations Specializations are provided for: * `virtual_ptr` * `const virtual_ptr&` * `T&` * `T&&` * `T*` * `std::shared_ptr`: defined in * `const std::shared_ptr&`: defined in * `std::unique_ptr`: defined in ### Members #### virtual_type ```c++ using virtual_type = ...; ``` The class used for method selection. It must be registered in Policy. For example, `virtual_type` in the following specializations are all `Class`: * `virtual_traits>` * `virtual_traits&, Policy>` * `virtual_traits` * `virtual_traits&, Policy>` #### peek ```c++ static auto peek(T arg) -> const ...&; ``` Returns a value for the purpose of obtaining a v-table pointer for `arg`. For example, `peek` returns a `const T&` for a `T&`, a `const T&`, a `T&&`, and a `std::shared_ptr`; and a `const virtual_ptr&` for a `const virtual_ptr&`. #### cast ```c++ template static decltype(auto) cast(T& obj); ``` Casts argument `obj` to the type expected by an overrider. For example, if a method takes a `virtual_`, an overrider for `Cat&` uses `virtual_traits` to cast a `Animal&` to a `Cat&`. #### rebind ```c++ template using rebind = ...; ``` For smart pointers only. Rebinds the smart pointer to a different type. For example, `virtual_traits, Policy>::rebind` is `std::shared_ptr`.