Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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 N> class Processor{ public: std::string operator()(std::string&& s) const { return Processor<N & (N-1)>()(Processor<N & ~(N-1)>()(s)); } }; template<> class Processor<0>{ public: std::string operator()(std::string&& s) const { return s; } }; 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
Shared lock
replace digits
Test 16(2020)
grid
javascript style arrays in c++
floyd alfa 1
Rotate array
-fno-elide-constructors
Replace substring poor
005#