File: Dispatch_output_iterator.cpp

package info (click to toggle)
cgal 4.5-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 69,700 kB
  • ctags: 118,537
  • sloc: cpp: 571,870; ansic: 110,997; sh: 725; python: 92; makefile: 87
file content (37 lines) | stat: -rw-r--r-- 905 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <vector>
#include <CGAL/iterator.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>

int main()
{
  std::vector<int> a;
  std::vector<double> b;
  std::vector<char> c;

  typedef CGAL::Dispatch_output_iterator< 
    CGAL::cpp0x::tuple<int, double, char>,
    CGAL::cpp0x::tuple<std::back_insert_iterator< std::vector<int> >,
                       std::back_insert_iterator< std::vector<double> >,
                       std::back_insert_iterator< std::vector<char> > 
                       > > Dispatch;

  Dispatch disp = CGAL::dispatch_output<int, double, char>(
    std::back_inserter(a),
    std::back_inserter(b),
    std::back_inserter(c));

  typedef boost::variant<int, double, char> var;
  var va = 23; var vb = 4.2; var vc = 'x';

  // goes to a
  *disp++ = va; 
  // goes to b
  *disp++ = vb; 
  // goes to c
  *disp++ = vc; 
  // goes to a
  *disp++ = 42;

  return 0;
}