Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
runtime template mode processor
//g++ 5.4.0 #include <iostream> #include <boost/algorithm/string.hpp> #include <boost/program_options.hpp> namespace po = boost::program_options; template<int> class Processor{}; enum Modes { md_tolower = 1, md_toupper = 2, md_capitalize = 4, md_trim_start = 8, md_trim_end = 16, md_normalize_spaces = 32, md_stem = 64, md_sort = 128, }; template<> class Processor<md_tolower>{ public: std::string operator()(std::string&& s) const { boost::to_lower(s); return s; } }; template<> class Processor<md_toupper>{ public: std::string operator()(std::string&& s) const { boost::to_upper(s); return s; } }; template<> class Processor<md_capitalize>{ public: std::string operator()(std::string&& s) const { return s; } }; template<> class Processor<md_trim_start>{ public: std::string operator()(std::string&& s) const { return s; // TODO } }; template<> class Processor<md_trim_end>{ public: std::string operator()(std::string&& s) const { return s; // TODO } }; template<> class Processor<md_normalize_spaces>{ public: std::string operator()(std::string&& s) const { return s; // TODO } }; template<> class Processor<md_stem>{ public: std::string operator()(std::string&& s) const { return s; // TODO } }; template<> class Processor<md_sort>{ public: std::string operator()(std::string&& s) const { return s; // TODO } }; int main(int argc, char** argv) { int mode = 0; po::options_description config_option_list("config options"); config_option_list.add_options() ("mode", po::value<int>(&mode)->default_value(0), "") ; po::options_description option_list; option_list.add(config_option_list); po::command_line_parser parser(argc, argv); parser.options(option_list); po::variables_map option_values; po::store(parser.run(), option_values); po::notify(option_values); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
merge without extra space Gap method ALgorithm
iuadhfaoiufs
CodeChef P1 MATMIN1
Scope guarding
kth smallest element in a matrix
Listas enlazadas - eliminar ocurrencias
cppOverride
sin_approximation
Memory_test
Print reverese string non repeated chars
Please log in to post a comment.