Feature #21

avatar

Provide a visitor mechanism for flusspferd::value

Added by Philipp Reh 528 days ago. Updated 273 days ago.

Status:Assigned Start:03/30/2009
Priority:Normal Due date:
Assigned to:avatarAristid Breitkreuz % Done:

0%

Category:C++-API
Target version:0.10

Description

flusspferd::value has a lot of is_foo and get_foo functions that would have to be tested in generic cases.
Proposed solution:
A visitor class has to implement the result_of protocol, namely provide a typedef result_type (which can be void).
apply_visitor (which should be added to flusspferd) then takes a visitor as argument and calls the appropriate operator()(T const &)
of the vistior.


Related issues

related to Feature #136 Easier (or make possible) to extend detail::convert for user-defined types New 10/23/2009
blocked by Feature #12 Evaluate conversion API Assigned 03/29/2009

History

Updated by Aristid Breitkreuz 528 days ago

avatar
  • Tracker changed from Bug to Feature

Updated by Aristid Breitkreuz 528 days ago

avatar
  • Status changed from New to Feedback
How should this cover the cases where
  1. the is_* functions are ambiguous,
  2. there are relevant subclasses, like array or function for object and
  3. especially the cases of null and void?

Updated by Aristid Breitkreuz 320 days ago

avatar
  • Target version set to 0.9

Updated by Aristid Breitkreuz 299 days ago

avatar
  • Status changed from Feedback to Assigned
  • Assigned to set to Aristid Breitkreuz

Pending the conversion overhaul, I'd like to see roughly the following API:

// assumption: MyClass1 and MyClass2 derive from native_object_base

struct visitor {
  typedef ... result_type;

  typedef boost::mpl::vector4<int, object, MyClass1, MyClass2> allowed_types;

  result_type operator()(int) {
    ...
  }

  result_type operator()(object const &) {
    ...
  }

  result_type operator()(MyClass1 &) {
    ...
  }

  result_type operator()(MyClass2 &) {
    ...
  }
};

Updated by Aristid Breitkreuz 273 days ago

avatar
  • Target version changed from 0.9 to 0.10

Also available in: Atom PDF