Boost logo

Boost :

From: Dylan Nicholson (dylan_nicholson_at_[hidden])
Date: 2002-02-26 18:52:05

 --- Jan Langer <jan_at_[hidden]> wrote: > On Tue,
26 Feb 2002, dylan_nicholson wrote:
> why not drop the defer() and say that calls to set
> can always be
> buffered. you can also commit (or flush) them be
> hand or at least on
> destruction of the attribute_set.
> i'll try to write an implementation of an (at least
> two) example
> attributes.

Non-obvious hidden behaviour. I think most users
would expect the the following to work:

 attribute_set a("file.txt");
 /* ... */
 std::ofstream str("file.txt");
 str << "some data";

> >(btw I really don't like the free function notation
> - it just looks
> >atypical. I understand it's purely a syntactical
> thing, but I think
> >you'll find it matters more in many developers
> minds. Also in this
> >case for implementations that do honour
> require/defer/commit it
> >probably requires a template friend declaration,
> which is not a good
> >idea).
> it does not require any friend declarations. and i

So how does require<..> (for instance) access the
internals of the attribute set, necessary in order to
mark somehow that this property is required.

> don't see why
> a.get <size> ()
> looks (or is) better than
> get <size> (a)
That's personal obviously. To me the former begins
with 'a.' thus puts me in the context of thinking
about a (= an attribute set). The latter begins with
such a generic term 'get' that until I read the entire
line I don't really know what's happening. I guess
it's similar to English speakers struggling with
languages where the verb might come before the object.

> another thing is that also calls of
> get <size> ("file.txt")
> must be possible without an attribute_set.

Perhaps. Note that this is not possible if get<>
takes only a templated basic_string (I mentioned this
in another post but I don't remember seeing it

I've played around with a few designs and the only
thing I can come up with that a) I'm happy with (*)
and b) can actually implement given MSVC's template
restrictions actually means that the only way to get
at a file's attributes is through a separate class:

int size = attributes("file.txt").get<size>();

(actually I haven't even made get<size> a template,
it's simply size() - how are you planning to get this
to work under MSVC? The essential assumption is that
all platform-specific code must be in a separate
source file, to avoid dragging in platform-specific
headers. I played around a bit with it and gave up
after failing to get template member explicit
instantiations to compile properly).

Dylan - Yahoo! Movies
- Vote for your nominees in our online Oscars pool.

Boost list run by bdawes at, gregod at, cpdaniel at, john at