This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Change default allocator?

On Thu, Nov 01, 2001 at 11:15:36PM +0100, Stefan Olsson wrote:
> Yes, but we would like to change the default allocator _without_ specifying
> this every time we create a new string...
> typedef std::basic_string <char, std::char_traits<char>,
> std_char_pthread_alloc > pthread_string;

Really, those kinds of typedefs are the way to go.  At the start of the
development work, they may just be "pass-through" names, like

    namespace our_project
        typedef  std::string         normal_string;
        typedef  std::string         threading_string;
        typedef  std::string         string_for_some_other_situation;
        typedef  std::vector<int>    container_of_ints;

    using our_project::string;
    using ...

but they provide hooks for easy project-wide changes; literally changing
one line such as threading_string and recompiling.  (A coder's dream!  :-)

If the underlying names have been used throughout, then the initial shift
to this style of naming will seem like a massive change, but it can be
largely mechanical.  It's definitely worth it.


If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]