On Tue, Dec 02, 2003 at 09:17:31AM +0000, Angus Leeming wrote: > Andre Poenitz wrote: > > At least making the LyXLex interface a bit similar to the > > std::streams would make me feel better. > > > > Patch attached. > > > + /// file is open and end of file is not reached > > + operator void *() const; > > I don't like this.
But that's what std::iostream does. > We already have problems catching implicit > conversions. Witness all those (bv()) arguments that are slowly being > changed to (true) or (false) and have nothing to do with the > existence of a BufferView anymore. > > > From a less political, more coding, point of view, why not 'operator > > bool() const;' if that is what you actually use it for? Exactly for the reason you mention: A void * is convertable to a bool, but not an integer (without cast). So this is safer. > + if (lex) > + vspace = VSpace(vsp); > > However, this isn't std::stream-like. Of course it is. 27.4.5.3 basic_ios iostate flags functions [lib.iostate.flags] operator void*() const Returns: If fail() then a null pointer; otherwise some non-null pointer to indicate success. Btw, I forgot to implement bool operator!() const. > The std::stream-like interface would be > if (lex.good()) > vspace = VSpace(vsp); I think if (!lex.fail()) is the correct idiom, at least that's what is required for the implementation of 'operator void *'. But I never needed to understand these details as if (is) and if (!is) do what is needed. > Nonetheless, it does look a lot nicer. It also doesn't address the > 'end_inset' thingy at all ;-) Surprise. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)