lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue 4550: Avoid "using namespace std; " in included files (Take 2)


From: Hans Åberg
Subject: Re: Issue 4550: Avoid "using namespace std; " in included files (Take 2) (issue 579240043 by address@hidden)
Date: Thu, 23 Jan 2020 20:57:23 +0100

> On 23 Jan 2020, at 13:43, lemzwerg--- via Discussions on LilyPond development 
> <address@hidden> wrote:
> 
>> Why is this ugly? std::string is really the name of the class.
> 
> No question, but I would prefer
> 
>  struct xxx {
>    using std:string;
> 
>    string foo;
>    string bar;
>    string baz;
>  }
> }
> 
> to
> 
>  struct xxx {
>    std::string foo;
>    std::string bar;
>    std::string baz;
>  }
> 
> for example, to increase legibility if there are many strings.

When using ones own namespace reusing names of std, then the external object 
must be qualified. For example,

namespace lly {

  class string {
  public:
    string(const std::string&);

    explicit operator std::string() const;
  };

  …

  inline string operator+(string& x, string& y) {
    return std::string(x) + std::string(y);
  }

} // namespace lly





reply via email to

[Prev in Thread] Current Thread [Next in Thread]