www.digitalmars.com         C & C++   DMDScript  

c++.stlsoft - Using auto_buffer for a stack-based allocator for std::string

reply "Adi Shavit" <adishavit_thisDoesNotBelongHere_ gmail.com> writes:
Hi,

   I need a (mostly) stack-based string.
I was wondering if it'd bee possible to use auto_buffer as the 
underlying component of an allocator that can be given to an 
std::string.
This way I can use these string with functions that accept and 
expect on std::string and still reap the benefits of stack access 
when my strings are not too big.

Has anyone done this before?
Does anyone have guidelines as to how to do this?

Thanks,
Adi
Sep 23 2012
parent reply "Matt Wilson" <matthewwilson acm.org> writes:
I did some work on similar lines when I was researching XSTL, for the 
material that was put back and later intended for XSTLv2 (when/if ever that 
happens). Bit rusty on it now, but it was _possible_; very ugly though.

Have you thought about using stlsoft::basic_static_string?

"Adi Shavit" <adishavit_thisDoesNotBelongHere_ gmail.com> wrote in message 
news:fowovkjjozrugnbalqrh forum.dlang.org...
 Hi,

   I need a (mostly) stack-based string.
 I was wondering if it'd bee possible to use auto_buffer as the underlying 
 component of an allocator that can be given to an std::string.
 This way I can use these string with functions that accept and expect on 
 std::string and still reap the benefits of stack access when my strings 
 are not too big.

 Has anyone done this before?
 Does anyone have guidelines as to how to do this?

 Thanks,
 Adi
 
Oct 06 2012
parent "Adi Shavit" <adishavit_thisDoesNotBelongHere_ gmail.com> writes:
Thanks.
I'll check out stlsoft::basic_static_string.
Adi

On Saturday, 6 October 2012 at 08:51:57 UTC, Matt Wilson wrote:
 I did some work on similar lines when I was researching XSTL, 
 for the
 material that was put back and later intended for XSTLv2 
 (when/if ever that
 happens). Bit rusty on it now, but it was _possible_; very ugly 
 though.

 Have you thought about using stlsoft::basic_static_string?

 "Adi Shavit" <adishavit_thisDoesNotBelongHere_ gmail.com> wrote 
 in message
 news:fowovkjjozrugnbalqrh forum.dlang.org...
 Hi,

   I need a (mostly) stack-based string.
 I was wondering if it'd bee possible to use auto_buffer as the 
 underlying component of an allocator that can be given to an 
 std::string.
 This way I can use these string with functions that accept and 
 expect on std::string and still reap the benefits of stack 
 access when my strings are not too big.

 Has anyone done this before?
 Does anyone have guidelines as to how to do this?

 Thanks,
 Adi
Oct 14 2012