Skip to content

Function proxy_typeid

// (1)
const std::type_info& proxy_typeid(const proxy_indirect_accessor<F>& operand) noexcept;

// (2)
const std::type_info& proxy_typeid(const proxy<F>& operand) noexcept;

Returns the typeid of the contained type of proxy<F> where F is a facade type built from basic_facade_builder.

  • (1) Let p be access_proxy<F>(operand), ptr be the contained value of p (if any). Returns typeid(std::decay_t<decltype(*std::as_const(ptr))>) if p contains a value, or otherwise, typeid(void).
  • (2) Let ptr be the contained value of operand (if any). Returns typeid(std::decay_t<decltype(ptr)>) if operand contains a value ptr, or otherwise, typeid(void).

These functions are not visible to ordinary unqualified or qualified lookup. It can only be found by argument-dependent lookup when proxy_indirect_accessor<F> (for rtti or indirect_rtti) or proxy<F> (for direct_rtti) is an associated class of the arguments.

Example

#include <iostream>

#include <proxy/proxy.h>

struct RttiAware : pro::facade_builder
    ::support<pro::skills::rtti>
    ::build {};

int main() {
  pro::proxy<RttiAware> p;
  std::cout << proxy_typeid(*p).name() << "\n";  // Prints "v" (assuming GCC)
  p = pro::make_proxy<RttiAware>(123);
  std::cout << proxy_typeid(*p).name() << "\n";  // Prints "i" (assuming GCC)
}

See Also