Using boost::program_options, I can not get my own option type to compile when it is declared inside a namespace. However outside of the workspace it compiles and works fine :
#include <boost/program_options.hpp>
using namespace boost;
using namespace boost::program_options;
struct my_type1 {
my_type1(int nn) : n(nn) {}
int n;
};
namespace nm {
struct my_type2 {
my_type2(int nn) : n(nn) {}
int n;
};
}
void validate(boost::any& v,
const std::vector<std::string>& values,
my_type1*, int) {
const std::string& s = validators::get_single_string(values);
v = any(my_type1(lexical_cast<int>(s)));
}
void validate(boost::any& v,
const std::vector<std::string>& values,
nm::my_type2*, int) {
const std::string& s = validators::get_single_string(values);
v = any(nm::my_type2(lexical_cast<int>(s)));
}
int main() {
options_description desc("options");
desc.add_options()
("m1", value<my_type1>() , "")
("m2", value<nm::my_type2>(), "")
;
return 0;
}
In main(), declaration of option 'm1' compiles but 'm2' does not... What is missing ? I am using boost_1_43_0 with gcc version 4.4.4.