Ticket #4656: foo.cpp

File foo.cpp, 1.3 KB (added by anonymous, 12 years ago)
Line 
1#include <vector>
2#include <string>
3
4#include <boost/program_options.hpp>
5
6namespace po = boost::program_options ;
7
8namespace foo
9{
10 class myclass
11 {
12 public:
13 friend std::ostream& operator<<(std::ostream &, myclass const &) ;
14 } ;
15
16 std::ostream& operator<<(std::ostream &out, myclass const & l){return out ;}
17
18 namespace bar
19 {
20 class anotherclass
21 {
22 public:
23 friend std::ostream& operator<<(std::ostream &,anotherclass const &) ;
24 } ;
25
26 std::ostream& operator<<(std::ostream &out, anotherclass const & l){return out ;}
27
28 void validate(boost::any& v, const std::vector<std::string>& values, anotherclass*, int)
29 {
30 }
31 } ;
32
33 using namespace foo ;
34 using namespace foo::bar ;
35
36 void validate(boost::any& v, const std::vector<std::string>& values, myclass*, int)
37 {
38 }
39
40 void validate(boost::any& v, const std::vector<std::string>& values, anotherclass*, int)
41 {
42 }
43
44
45 class options
46 {
47 public:
48 options()
49 {
50 generic_options_.add_options()
51 ("option1", po::value<myclass>(&myclass_obj), "test")
52 ("option2", po::value<anotherclass>(&anotherclass_obj), "test")
53 ;
54 }
55 private:
56 myclass myclass_obj ;
57 anotherclass anotherclass_obj ;
58 po::options_description generic_options_ ;
59 } ;
60} ;
61
62
63
64int main(int argc, char** argv)
65{
66 foo::options opts_() ;
67}
68