Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Class template visitor_ptr_t

boost::visitor_ptr_t — Adapts a function pointer for use as a static visitor.


// In header: <boost/variant/visitor_ptr.hpp>

template<typename T, typename R> 
class visitor_ptr_t : public static_visitor<R> {
  // construct/copy/destruct
  explicit visitor_ptr_t(R (*)(T));

  // static visitor interfaces
  R operator()(unspecified-forwarding-type);
  template<typename U> void operator()(const U&);


Adapts the function given at construction for use as a static visitor of type T with result type R.

visitor_ptr_t public construct/copy/destruct

  1. explicit visitor_ptr_t(R (*)(T));


    Constructs the visitor with the given function.

visitor_ptr_t static visitor interfaces

  1. R operator()(unspecified-forwarding-type operand);
    template<typename U> void operator()(const U&);


    If passed a value or reference of type T, it invokes the function given at construction, appropriately forwarding operand.


    Returns the result of the function invocation.


    The overload taking a value or reference of type T throws if the invoked function throws. The overload taking all other values always throws bad_visit.