Document No.: X3J16/93/0122 WG21/N329 Date: 22/09/93 Project: Programming Language C++ Reply to: Uwe Steinmueller Siemens Nixdorf uwe.steinmueller@mch.sni.de Some changes to the string, wstring and dynarray classes ======================================================== 1. Inconsistent use of capacity in these classes and removing class Size_T ------------------------------------------------------------- Class Size_T is not only very ugly but does also not solve all the problems it should: string s(10); which is called ? (1) string(char c, size_t rep = 1) (2) string(Size_T res_arg); (1) is called, but that does not mean the caller wanted it I propose an alternative solution: We have an enum Capacity to use with string, wstring, and dynarray enum Capacity { Reserve, DefaultSize } replace: (w)string(Size_T res_arg); by: (w)string(size_t res_arg, enum Capacity); to be called as: string s(10, Capacity); Changes in dynarray (to get it consistent) remove: all res_arg = 0 default arguments from the constructors replace: dynarray(Size_T size, size_t res_arg = 0) by: dynarray(size_t size, enum Capacity); (1) dynarray a1(10, Reserve); (2) dynarray a1(10, DefaultSize); (1) is an dynarray of size() == 0 and a capacity of 10 (2) is an dynarray of size() == 10 and all values constructed with T's default constructor (2) is needed as otherwise there might be an ambiguity with dynarray(const T&t, size_t rep = 1) in the case T is an integral type 2. Change all members in string and wstring having the signature xxx(const string& str, size_t n = NPOS) --------------------------------------------------------------- change: xxx(const string& str, size_t n = NPOS) to: xxx(const string& str, size_t pos = 0, size_t n = NPOS) This change makes these functions more useful. Why should it be only interesting to have the first n elements of the string? 3. Add a full set of overloaded functions in the case of the member functions xxx(const string& str, size_t n = NPOS) --------------------------------------------------------------- these are if proposal in 2 would be accepted: xxx(const string& str, size_t pos = 0, size_t n = NPOS) Let me use find(const string& str, size_t pos = 0, size_t n = NPOS) as an example find(char c, size_t pos = 0); // find one character find(const char* cb, size_t pos = 0, size_t n = NPOS) // if n == NPOS fins the NTS cb otherwise the n first // characters of cb This proposal has two reasons: 1. getting better performance 2. reserve these signatures to the implementations that we do not get ambiguities if an implementation would add it The dynarray and my former string class proposal followed this rule, we should get a consensus on this by the library WG. -- Current address: Uwe Steinmueller Siemens Nixdorf SWZ Vianen Mijlweg 7 NL, 4130 EA, Vianen Netherlands steinmueller.via@sni.de