🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2378

Inconsistent use of default arguments in string class?

#2378
From: Harald Winroth
Date: Wed, 01 Nov 1995 10:51
33 lines
2058 bytes
I have a question regarding the proposed string class. In the April WP 
there are string member functions taking both string and char* arguments. 
For example, there are

        class basic_string : ... {
          ...
                basic_string& append(const basic_string& str, size_t pos=0,
                                     size_t n=NPOS);
                basic_string& append(const charT* s, size_t n);
          ...
        };

As I understand the WP, 

        str.append("abc123", 3)

would append "abc" to str, while

        str.append((string)"abc123", 3) 

would append "123" to str. Is that interpretation correct? If so, I think
this could cause a lot of bugs in application code. Is there a good reason 
why string member function taking  charT* arguments won't also take the 
same position/size arguments as their basic_string-argument counterparts?

-----------------------------------------------------------------------------
Harald Winroth     | Computational Vision and Active Perception Laboratory,
harald@bion.kth.se | Royal Institute of Technology, S-10044 Stockholm, Sweden
-----------------------------------------------------------------------------
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <HARALD.95Nov1105205@moon.bion.kth.se>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 01 Nov 95 10:51:30 GMT
Approved: fjh@cs.mu.oz.au
From: harald@bion.kth.se (Harald Winroth)
Newsgroups: comp.std.c++
Subject: Inconsistent use of default arguments in string class?
X-Original-Date: 01 Nov 1995 09:52:05 GMT
Organization: CVAP/NADA, Royal Institute of Technology, Stockholm, Sweden
Message-ID: <HARALD.95Nov1105205@moon.bion.kth.se>
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMJdRQeEDnX0m9pzZAQGHbQF/Y5QPjRzqLUxmKXOV+675ksCfyhCY68jm
 +e+CAA0B+CoCC45QlmBRZnBj2RzXBRyy
 =Kqp3