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.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > C++

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-15-2008, 01:34 AM
Stephen M. Webb
 
Posts: n/a
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! ]

Reply With Quote
  #2 (permalink)  
Old 08-15-2008, 05:45 AM
Pete Becker
 
Posts: n/a
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! ]

Reply With Quote
  #3 (permalink)  
Old 08-17-2008, 04:20 AM
Lance Diduck
 
Posts: n/a
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! ]

Reply With Quote
  #4 (permalink)  
Old 08-18-2008, 09:59 PM
Stephen M. Webb
 
Posts: n/a
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! ]

Reply With Quote
  #5 (permalink)  
Old 08-19-2008, 01:38 AM
Pete Becker
 
Posts: n/a
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! ]

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > C++


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:46 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Flights | Loans | Mortgage Loans | Credit Cards | Personal Loans



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114