Home » U++ Library support » U++ Core » why not "T & Add(const T & x)" in all containers
|
|
|
|
|
Re: why not "T & Add(const T & x)" in all containers [message #29450 is a reply to message #29449] |
Thu, 21 October 2010 11:54 |
|
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
i thought of it. and there is a solution in the code.
i just split the function, i.e. Set:
original:
void Set(int i, const T& x, int count = 1);
split:
T& Set(int i, const T& x);
void Set(int i, const T& x, int count);
which is syntactically the same, the omited count defaults to setting only one element and returns the ref..no changes in user code. when using count, the other function evaluates.
insert is same:
void Insert(int i, const T& x, int count = 1);
split:
T& Insert(int i, const T& x);
void Insert(int i, const T& x, int count);
i'm actually working with the code for some while now, and haven't noticed any misbehavior, so the sub layers of upp deal well with it. consider it again. i think it can contribute to the comfort using upp containers, and of corse again a little bit of speed optimization at user level..and shorten the code a bit.
attached the current source based snapshot..
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri May 03 21:24:59 CEST 2024
Total time taken to generate the page: 0.01918 seconds
|