Opened 21 years ago
Closed 19 years ago
#61 closed Bugs (Invalid)
regex iterator requirement
| Reported by: | lfarkas | Owned by: | John Maddock | 
|---|---|---|---|
| Milestone: | Component: | regex | |
| Version: | None | Severity: | |
| Keywords: | Cc: | 
Description
regex require that iterator (eg for regex_match) has default constructor. AFAIK it's not a requirement for any (neither bidirectional) iterator to has a default constructor. eg for user defined iterator sometime it's a preformance decrease for iterator. eg. I'd like to use regex to search a file. if the file fit into the memory I use wstring's iterator, but if not I have to create an own bi_istream_iterator (since std::istream_iterator is not bidirectional:-(). after that I made an iterator which encapsulate these two iterator, but this hasn't deafult constructor and if I have to make a default one, than I'have to redesign it and add another bool member. what I realy wan't that the encapsulator iterator be as samll as possible, but it's getting harder and harder:-((( IMHO it's a bug in regex implementation. yours.
Change History (3)
comment:2 by , 21 years ago
Logged In: YES 
user_id=405207
thanks for the tipp again, but another bugreport in:
boost/regex/detail/fileiter.cpp
(which would be usefult to make public anyway)
in mapfile (for win32) the following member should have to 
be const:
-----------------------------------
   const char* begin(){ return _first; }
   const char* end(){ return _last; }
   size_t size(){ return _last - _first; }
   bool valid(){ return (hfile != 0) && (hfile != 
INVALID_HANDLE_VALUE); }
-----------------------------------
the correct form:
-----------------------------------
   const char* begin() const { return _first; }
   const char* end() const { return _last; }
   size_t size() const { return _last - _first; }
   bool valid() const { return (hfile != 0) && (hfile != 
INVALID_HANDLE_VALUE); }
-----------------------------------
and if I send it to you another cosmetic fix. I always 
prefere member initilaization over assigment:
-----------------------------------
   mapfile(){ hfile = hmap = 0; _first = _last = 0; }
   mapfile(const char* file){ hfile = hmap = 0; _first = 
_last = 0; open(file); }
-----------------------------------
my prefered version:
-----------------------------------
   mapfile() : hfile(0), hmap(0), _first(0), _last(0) {}
   mapfile(const char* file) : hfile(0), hmap(0), _first(0), 
_last(0) { open(file); }
-----------------------------------
and for the unix version:
-----------------------------------
   mapfile(){ hfile = 0; _size = 0; _first = _last = 0; }
   mapfile(const char* file){ hfile = 0; _size = 0; _first = 
_last = 0; open(file); }
-----------------------------------
the new ones;
-----------------------------------
   mapfile() : hfile(0), _size(0), _first(0), _last(0) {}
   mapfile(const char* file) : hfile(0), _size(0), 
_first(0), _last(0) { open(file); }
-----------------------------------
yours.
comment:3 by , 19 years ago
| Status: | assigned → closed | 
|---|
  Note:
 See   TracTickets
 for help on using tickets.
    