
Sebastian Redl wrote:
Robert Kawulak wrote:
Don't worry, I am planning to finish this. But looking at the (quite crowded) review queue I suppose there is no hurry... ;-)
I think as it is now, if you can find yourself a review manager, you could effectively jump most of the queue.
Just saying ...
I'm glad this library is moving toward prime time. Looking over the docs, it looks pretty good -- pretty certain I could replace my date-time implementation with these. I have a few comments below. Anyway, I'm willing to be the review manager if that helps. I'm a little concerned with the dynamic changeability of the checking policy on bounded. I think that design decision will lead to function call overhead not present in the original implementation...even for bounded_int where the constraints can all be inline and fixed at compile time. I'd rather have 2 types if need be to allow maximum efficiency for the static cases. Couple thoughts on the docs. I didn't see Christopher Diggins acknowledged anywhere. He also took the date-time ideas and expanded them -- writing an article for C/C++ Users Journal. Here's some links: http://www.cdiggins.com/constrained_value.hpp http://www.artima.com/weblogs/viewpost.jsp?thread=79470 Second thing is that it would be nice to have tutorial style docs to walk someone thru use of writing a custom constraints (ok there's a simple one there), but also how to replace the provided exceptions with custom exceptions -- this isn't clear in the docs. I need to do custom exceptions in date-time -- the code there looks like: //! Exception type for gregorian year struct bad_year : public std::out_of_range { bad_year() : std::out_of_range(std::string("Year is out of valid range: 1400..10000")) {} }; //! Policy class that declares error handling gregorian year type typedef CV::simple_exception_policy<unsigned short, 1400, 10000, bad_year> greg_year_policies; Anyway the docs should describe how to do this. I also may have another contribution to this library in the future. I've written a constrained_string type which provides similar capabilities for strings. A typical use case is to only allow construction with a fixed set of strings -- basically like an enum: class image_string_policy : public string_set_policy<std::string, image_string_policy> { public: static set_type* init_set() { set_type* s = new set_type(); s->insert("png"); s->insert("jpg"); s->insert("jpeg"); s->insert("tiff"); return s; } }; //must construct with png, jpg, jpeg or tiff -- null is invalid typedef constrained_string<image_string_policy, std::string> image_string_type; //must construct with png, jpg, jpeg or tiff -- null ok typedef constrained_string_with_null<image_string_policy, std::string> image_string_type_with_null; image_string_type is("jpg"); //ok image_string_type is2("garbage"); //exception Another form allows fancy regex checking: class digit_string_policy : public regex_policy<std::string, digit_string_policy> { public: static const regex_type& get_regex() { static const regex_type pattern("\\d{4}"); return pattern; } }; typedef constrained_string<digit_string_policy, std::string> digit_string_type; digit_string_type ds("1234"); //ok digit_string_type ds2("12"); //exception-- four digits required Jeff