| 97 | * Proposal to include a plugable extractor to `plot_range()` |
| 98 | |
| 99 | In general, containers will store other things than double. Starting simple, I want to be able to |
| 100 | plot `std::vector<int>`. This is very easy to support. Add a function: |
| 101 | |
| 102 | {{{ |
| 103 | #!cpp |
| 104 | template<class Iter, class DoubleExtractor > |
| 105 | plot& plot_range( Iter start, Iter end, DoubleExtractor double_extractor) |
| 106 | { |
| 107 | return your_old_plot_range( |
| 108 | boost::make_transform_iterator(start, double_extractor), |
| 109 | boost::make_transform_iterator(end , double_extractor) |
| 110 | ); |
| 111 | } |
| 112 | }}} |
| 113 | |
| 114 | This have other implications, for example if we have list<Human> hl, and struct get_age_functor { ... }; |
| 115 | We can: |
| 116 | |
| 117 | {{{ |
| 118 | #!cpp |
| 119 | svg << plot_range( hl.begin(), hl.end(), get_age_functor() ); // fun stuff :) |
| 120 | }}} |