#ifndef iUCKfY0lAetXcXu8Ykh6wMB3KhQ #define iUCKfY0lAetXcXu8Ykh6wMB3KhQ #include #include #include namespace IdListImpl { using namespace boost::xpressive; struct push_impl { typedef void result_type; template void operator()(Set &s, Value const &from, Value const &until) const { for (Value i = from; i <= until; ++i) s.insert(i); } }; function::type const pushRange = {{}}; template struct IdList : std::set { explicit IdList(char *s = (char*) "") { cregex number = (s1= +_d) [insert(boost::xpressive::ref(*this), as(s1))]; cregex range = ((s1= +_d) >> as_xpr('-') >> (s2= +_d)) [pushRange(boost::xpressive::ref(*this), as(s1), as(s2))]; cregex list = *((range | number) >> *( as_xpr(',') >> (range | number))); assert(regex_match(s, list)); } template IdList(IdList &src) { for (auto i : src) { assert(i <= std::numeric_limits::max()); this->insert(i); } } }; } // IdListImpl using IdListImpl::IdList; #endif // iUCKfY0lAetXcXu8Ykh6wMB3KhQ