![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
basic_regex and allocators
Folks,
Does anybody know the reason why tr1::basic_regex (and std::basic_regex) is not templated on an allocator type? The construction of a basic_regex requires some sort of (potentially significant) allocation. Using the default new operator is great and all, but precludes the library user from doing the same sort of memory allocation customization available to, say, containers. Was the intention that basic_regex be like the IOStreams iword/pword facility and provide absolutely no customization point for memory handling, or is this just an oversight by the committee? -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|
|||
|
Re: basic_regex and allocators
On 2008-08-14 14:34:31 -0400, "Stephen M. Webb"
<stephen.webb@bregmasoft.com> said: > > Does anybody know the reason why tr1::basic_regex (and > std::basic_regex) is not templated on an allocator type? The > construction of a basic_regex requires some sort of (potentially > significant) allocation. Using the default new operator is great and > all, but precludes the library user from doing the same sort of memory > allocation customization available to, say, containers. > > Was the intention that basic_regex be like the IOStreams iword/pword > facility and provide absolutely no customization point for memory > handling, or is this just an oversight by the committee? Seems to me that the reason was that there is no specified allocation strategy, so no way to write a reasonable allocator. Unlike vector, which allocates contiguous memory, and list, which allocates nodes, you have no idea what the memory needs of basic_regex are. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book) [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|
|||
|
Re: basic_regex and allocators
> you have no idea what the memory needs of basic_regex are. > Pete NB: The locales library exhibits the same feature. So if it is good enough for locales, it is good enough for regex. However, also note that another popular parsing library, xerces, has the ability to specify *at runtime* just what allocator you want to use. Lance -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|
|||
|
Re: basic_regex and allocators
On Aug 15, 12:45 am, Pete Becker <p...@versatilecoding.com> wrote:
> > Seems to me that the reason was that there is no specified allocation > strategy, so no way to write a reasonable allocator. Unlike vector, > which allocates contiguous memory, and list, which allocates nodes, you > have no idea what the memory needs of basic_regex are. Hmm, the regex match_results class specifies an allocator but has no specified allocation stratgy. A reasonable implementation strategy for match_results could be vector-like, list-like, or even tree-like. For consistency, then, either the allocator for match_results should be removed as a customization point or else the required allocation strategy should be clearly specified in the standard. Alternatively, since a match_result is a container of sub_match objects, it should be specified as a container adapter and the library user be allowed to specify the actual container as a customization point, just like std::stack or std::queue. The problem with not providing an allocation customization point for regular expressions is that they tend to get used like strings, and without a way to customize allocations their use could quickly become problematic in long running applications. Developers will choose to use alternative libraries that do not fragment the free store and blow cache coherency, and that sort of defeats the entire purpose of having a facility in the standard library. If not specifying an allocation strategy is the reason for not providing an allocation customization point for basic_regex, why not just specify a required allocation strategy? -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
|
|||
|
Re: basic_regex and allocators
On 2008-08-16 17:20:00 -0400, Lance Diduck <lancediduck@nyc.rr.com> said:
> > >> you have no idea what the memory needs of basic_regex are. >> Pete > > NB: The locales library exhibits the same feature. So if it is good > enough for locales, it is good enough for regex. I wasn't involved in the design of lcoales, but I was involved in the design of regex. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book) [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|