Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-08-21 18:44:10


"Rainer Deyke" <rainerd_at_[hidden]> writes:

> David Abrahams wrote:
>> A single component of a path is still a path, and it
>> shouldn't devolve into a string.
>
> I disagree. While a path with just one component can exist, a single path
> component is no more a path than an element in an array of integers is
> itself an array of integers.
> A single component of a path is a name, and therefore naturally
> represented by 'std::string'.

Are you seriously saying that path("foo") is not a path? If you want
to make paths into containers of strings, give them iterators and
operator[], and I'll accept the name back() as a way to get the leaf
string.

> However, I would still prefer that 'path::leaf' returns a path instead of a
> string. My reasoning is practical rather than ideological.

As is mine.

> If 'p' is a native path

Is there such a thing as a "native path"? I thought all path strings,
even if they began as native, got converted immediately into some "portable
generic" format internally.

> then 'p.leaf()' may contain any character that is supported by the
> native file system, which may include slashes. When 'p.leaf()' is
> then converted back into a 'filesystem::path', the resulting path
> will have different sematics than intended. This strikes me as very
> dangerous.

Oh, is that what happens now? Yipes!

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk