Re: C++ question about auto_ptr

2015-05-09 Thread Jean-Marc Lasgouttes
Le 08/05/2015 23:10, Georg Baum a écrit : I have many places like in the patch below. Is there a reason why I should keep the auto_ptr instead of a naked pointer? What is it good for? Usually it is used for exception safety: If you use a raw pointer, you need to delete it in the catch clause, e

Re: C++ question about auto_ptr

2015-05-09 Thread Abdelrazak Younes
On 09/05/2015 11:37, Jean-Marc Lasgouttes wrote: Le 09/05/2015 09:18, Abdelrazak Younes a écrit : On 08/05/2015 22:13, Jean-Marc Lasgouttes wrote: With C++11, auto_ptr is deprecated and we get warnings. I am trying to see how we can get rid of it. unique_ptr is new to C++11, so I'd rather avoi

Re: C++ question about auto_ptr

2015-05-09 Thread Jean-Marc Lasgouttes
Le 09/05/2015 09:18, Abdelrazak Younes a écrit : On 08/05/2015 22:13, Jean-Marc Lasgouttes wrote: With C++11, auto_ptr is deprecated and we get warnings. I am trying to see how we can get rid of it. unique_ptr is new to C++11, so I'd rather avoid that. Why that? unique_ptr is supported since

Re: C++ question about auto_ptr

2015-05-09 Thread Abdelrazak Younes
On 08/05/2015 22:13, Jean-Marc Lasgouttes wrote: With C++11, auto_ptr is deprecated and we get warnings. I am trying to see how we can get rid of it. unique_ptr is new to C++11, so I'd rather avoid that. Why that? unique_ptr is supported since gcc 4.4 released in 2009: https://gcc.gnu.org/gc

Re: C++ question about auto_ptr

2015-05-08 Thread Georg Baum
Jean-Marc Lasgouttes wrote: > With C++11, auto_ptr is deprecated and we get warnings. > > I am trying to see how we can get rid of it. unique_ptr is new to C++11, > so I'd rather avoid that. Why not use unique_ptr fpr C++11 and auto_ptr else? The difference is in the copying semantics, which do

C++ question about auto_ptr

2015-05-08 Thread Jean-Marc Lasgouttes
With C++11, auto_ptr is deprecated and we get warnings. I am trying to see how we can get rid of it. unique_ptr is new to C++11, so I'd rather avoid that. I have many places like in the patch below. Is there a reason why I should keep the auto_ptr instead of a naked pointer? What is it good f

Re: C++ question about const

2015-04-25 Thread Scott Kostyshak
On Sat, Apr 25, 2015 at 3:42 PM, Vincent van Ravesteijn wrote: > Scott Kostyshak schreef op 22-4-2015 om 3:37: > > In many cases variables are defined const because they are not going to be > changed. This does not mean that it was not allowed to be changed by design. > > In this case, I would ju

Re: C++ question about const

2015-04-25 Thread Vincent van Ravesteijn
Scott Kostyshak schreef op 22-4-2015 om 3:37: My question is in regards to the patch I propose for #6173: http://www.lyx.org/trac/attachment/ticket/6173/0001-Update-previews-when-going-to-a-bookmark-6173.patch I move the definition of cur up because I need it before the return. I then need to pa

C++ question about const

2015-04-21 Thread Scott Kostyshak
My question is in regards to the patch I propose for #6173: http://www.lyx.org/trac/attachment/ticket/6173/0001-Update-previews-when-going-to-a-bookmark-6173.patch I move the definition of cur up because I need it before the return. I then need to pass it to notifyCursorLeavesOrEnters(), which req

Re: C-question

2006-04-09 Thread Bo Peng
> There is no need for the cast in C (as the conversion is automatic), I have not checked C99 standard on this issue, but C has improved on such things and may no longer allow this dangerous implicit conversion. > and there is no need for malloc in C++ (as there's 'new' etc). Right. Poeple still

Re: C-question

2006-04-09 Thread Andre Poenitz
On Fri, Apr 07, 2006 at 08:42:45PM -0500, Bo Peng wrote: > > commandLine = malloc (commandLineLength); > > commandLine = (char*)malloc (commandLineLength); > > Usually (to be safe, and is the case for any other type), > > commandLine = (char*)malloc (commandLineLength*sizeof(char)); There i

Re: C-question

2006-04-08 Thread Uwe Stöhr
Bo Peng wrote: commandLine = malloc (commandLineLength); commandLine = (char*)malloc (commandLineLength); Many thanks for this. I works and I can now start MSYS. regards Uwe

Re: C-question

2006-04-07 Thread Enrico Forestieri
On Sat, Apr 08, 2006 at 03:39:40AM +0200, Uwe Stöhr wrote: > Could anybody help me with a little C-Problem. Attached is a small > sourcecode that I have to compile. G++ tells me: > > D:\LyXSVN>g++ createprocess.c -o CreateProcess.exe > createprocess.c: In function `int main(int, char**)': > crea

Re: C-question

2006-04-07 Thread Bo Peng
> commandLine = malloc (commandLineLength); commandLine = (char*)malloc (commandLineLength); Usually (to be safe, and is the case for any other type), commandLine = (char*)malloc (commandLineLength*sizeof(char)); Bo

C-question

2006-04-07 Thread Uwe Stöhr
Could anybody help me with a little C-Problem. Attached is a small sourcecode that I have to compile. G++ tells me: D:\LyXSVN>g++ createprocess.c -o CreateProcess.exe createprocess.c: In function `int main(int, char**)': createprocess.c:25: error: invalid conversion from `void*' to `char*' Any

Re: C++ question

2005-06-11 Thread Andre Poenitz
On Sun, Jun 05, 2005 at 09:41:26PM +0100, Angus Leeming wrote: > I feel like a bit of an idiot asking this, but what's the C++ way to insert > some data into an existing file? Write a new one. It's about the only way that has certain guarantees to work without sacrificing black roosters. Andre'

Re: C++ question

2005-06-06 Thread Angus Leeming
Lars Gullik Bjønnes wrote: | I feel like a bit of an idiot asking this, but what's the C++ way to | insert some data into an existing file? How would you do it in any other language? At end is easy. At start is more tricky... If it were a memory buffer how would you do it then? (memmove perhap

Re: C++ question

2005-06-05 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | I feel like a bit of an idiot asking this, but what's the C++ way to | insert some data into an existing file? How would you do it in any other language? At end is easy. At start is more tricky... If it were a memory buffer how would you do it then? (

C++ question

2005-06-05 Thread Angus Leeming
I feel like a bit of an idiot asking this, but what's the C++ way to insert some data into an existing file? I tried this: std::fstream fs(configure_file); std::string buffer; bool success = false; while (fs) { std::fstream::pos_type const start_of_line = fs.tellp(); std::getli

Re: C++ question. Is this safe?

2005-02-20 Thread Asger Ottar Alstrup
Andre Poenitz wrote: I am not sure the message is valid. Sure, the compiler sees a tmporary and returning a reference to a part of something refered to by the temporary. However, that thing is not a temporary but lives in a structure outside. The compiler does not know, but we do. So my guess is t

Re: C++ question. Is this safe?

2005-02-19 Thread Andre Poenitz
On Tue, Feb 15, 2005 at 10:58:13AM +, Angus Leeming wrote: > class Mover {...}; > class SpecialisedMover : public Mover {...}; > > class Movers { > public: > /// @c returns the Mover registered for format @c fmt. > Mover const & operator()(std::string const & fmt) const > { >

Re: C++ question. Is this safe?

2005-02-15 Thread Asger Alstrup
Angus Leeming wrote: I read that as saying that the code in the mail at the start of this thread is perfectly safe, don't you? Well, we also have: template class _Tree { const_iterator find(const key_type& _Keyval) const { // find an element in nonmutable seque

Re: C++ question. Is this safe?

2005-02-15 Thread Angus Leeming
Asger Alstrup wrote: > Angus Leeming wrote: >> That will require an MSVC user (Asger) to check his >> std::map::const_iterator implementation. > > I'm not sure this is what you are looking for, but here is some of the > code for the map::const_iterator in MSVC 7.1: > > class const_iterator > : p

Re: C++ question. Is this safe?

2005-02-15 Thread Asger Alstrup
Angus Leeming wrote: That will require an MSVC user (Asger) to check his std::map::const_iterator implementation. I'm not sure this is what you are looking for, but here is some of the code for the map::const_iterator in MSVC 7.1: class const_iterator : public _Bidit

Re: C++ question. Is this safe?

2005-02-15 Thread Angus Leeming
Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > > | class Mover {...}; > | class SpecialisedMover : public Mover {...}; >> > | class Movers { > | public: > | /// @c returns the Mover registered for format @c fmt. > | Mover const & operator()(std::string const & f

Re: C++ question. Is this safe?

2005-02-15 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | class Mover {...}; | class SpecialisedMover : public Mover {...}; > | class Movers { | public: | /// @c returns the Mover registered for format @c fmt. | Mover const & operator()(std::string const & fmt) const | { | SpecialsMap::cons

C++ question. Is this safe?

2005-02-15 Thread Angus Leeming
class Mover {...}; class SpecialisedMover : public Mover {...}; class Movers { public: /// @c returns the Mover registered for format @c fmt. Mover const & operator()(std::string const & fmt) const { SpecialsMap::const_iterator const it = specials_.find(fmt); return (i

Re: (OFFTOPIC) C++ question

2003-11-05 Thread Angus Leeming
Andre Poenitz wrote: > Aehm... that's not LyX, is it? weee, grep for either boost::function or boost::bind in the lyx srcs... -- Angus

Re: (OFFTOPIC) C++ question

2003-11-05 Thread Andre Poenitz
On Wed, Nov 05, 2003 at 01:46:06PM +, Angus Leeming wrote: > Andre Poenitz wrote: > > You do not expect me to understand that, do you? > > Think of it as the consequences of your suggestion and ask forgiveness > ;-) > > Actually, this isn't so complicated is it: > > boost::function

Re: (OFFTOPIC) C++ question

2003-11-05 Thread Angus Leeming
Andre Poenitz wrote: > You do not expect me to understand that, do you? Think of it as the consequences of your suggestion and ask forgiveness ;-) Actually, this isn't so complicated is it: boost::function set_value = Node::set_conc; Node node; double val = 3; //

Re: (OFFTOPIC) C++ question

2003-11-05 Thread Andre Poenitz
On Wed, Nov 05, 2003 at 12:53:02PM +, Angus Leeming wrote: > Andre Poenitz wrote: > > Well... this exposes an implementation detail (type of container) to > > the outer world. Moreover, people are tempted to use ++ on > > iterators, whereas not too many poeple would use (&element(3) + 1) > > >

Re: (OFFTOPIC) C++ question

2003-11-05 Thread Angus Leeming
Lars Gullik Bjønnes wrote: > boost::function set_value = ... > > a bit more taxing on the complier but fewer surprises in the syntax. > (IMHO of course.) Last time I tried, gcc fell over on this syntax... ... nope. Works perfectly. Thanks, Lars. -- Angus

Re: (OFFTOPIC) C++ question

2003-11-05 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | Andre Poenitz wrote: >> Well... this exposes an implementation detail (type of container) to >> the outer world. Moreover, people are tempted to use ++ on >> iterators, whereas not too many poeple would use (&element(3) + 1) >> >> So _I_'d prefer the ac

Re: (OFFTOPIC) C++ question

2003-11-05 Thread Angus Leeming
Andre Poenitz wrote: > Well... this exposes an implementation detail (type of container) to > the outer world. Moreover, people are tempted to use ++ on > iterators, whereas not too many poeple would use (&element(3) + 1) > > So _I_'d prefer the accessor functions. Hmpfff. I did as you suggested

Re: (OFFTOPIC) C++ question

2003-11-04 Thread John Levon
On Tue, Nov 04, 2003 at 01:15:27PM +, Angus Leeming wrote: > Grrr > Windmills. The new official catchphrase ? john -- Khendon's Law: If the same point is made twice by the same person, the thread is over.

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Andre Poenitz
On Tue, Nov 04, 2003 at 03:47:37PM +, Angus Leeming wrote: > However, LyX is trying to use iterators more, not less, and you are > driving that effort. By replacing PragraphList::iterator with integer offsets? Hah... you reveal my secret plan... Andre'

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Angus Leeming
Andre Poenitz wrote: > On Tue, Nov 04, 2003 at 02:00:21PM +, Angus Leeming wrote: >> Andre Poenitz wrote: >> >> > On Tue, Nov 04, 2003 at 12:19:25PM +, Angus Leeming wrote: >> >> I have a container that currently allows the user to alter the >> >> Node container. I want to allow the user

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Andre Poenitz
On Tue, Nov 04, 2003 at 02:00:21PM +, Angus Leeming wrote: > Andre Poenitz wrote: > > > On Tue, Nov 04, 2003 at 12:19:25PM +, Angus Leeming wrote: > >> I have a container that currently allows the user to alter the Node > >> container. I want to allow the user to be able to alter the Node

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Angus Leeming
Andre Poenitz wrote: > On Tue, Nov 04, 2003 at 12:19:25PM +, Angus Leeming wrote: >> I have a container that currently allows the user to alter the Node >> container. I want to allow the user to be able to alter the Node >> contents but to not be able to insert, erase Nodes from the vector. >>

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Angus Leeming
Andre Poenitz wrote: > On Tue, Nov 04, 2003 at 12:37:00PM +, Angus Leeming wrote: >> >> What's the best way to proceed? >> > >> > >> > /// The element list is immutable. >> > //std::vector const & elements() const { return >> > elements_; } Element const & element(

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Andre Poenitz
On Tue, Nov 04, 2003 at 12:37:00PM +, Angus Leeming wrote: > >> What's the best way to proceed? > > > > > > /// The element list is immutable. > > //std::vector const & elements() const { return > > elements_; } Element const & element(size_t i) const { > >

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Angus Leeming
Andre Poenitz wrote: > On Tue, Nov 04, 2003 at 12:19:25PM +, Angus Leeming wrote: >> I have a container that currently allows the user to alter the Node >> container. I want to allow the user to be able to alter the Node >> contents but to not be able to insert, erase Nodes from the vector. >>

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | I have a container that currently allows the user to alter the Node | container. I want to allow the user to be able to alter the Node | contents but to not be able to insert, erase Nodes from the vector. Don't return the vector but have an accessor f

Re: (OFFTOPIC) C++ question

2003-11-04 Thread Andre Poenitz
On Tue, Nov 04, 2003 at 12:19:25PM +, Angus Leeming wrote: > I have a container that currently allows the user to alter the Node > container. I want to allow the user to be able to alter the Node > contents but to not be able to insert, erase Nodes from the vector. > > What's the best way to

(OFFTOPIC) C++ question

2003-11-04 Thread Angus Leeming
I have a container that currently allows the user to alter the Node container. I want to allow the user to be able to alter the Node contents but to not be able to insert, erase Nodes from the vector. What's the best way to proceed? /** \c ElementList is a convenient container of the nodes *

Re: C++ question

2003-09-24 Thread Angus Leeming
On Wednesday 24 September 2003 1:44 pm, Andre Poenitz wrote: > On Wed, Sep 24, 2003 at 02:29:44PM +, Angus Leeming wrote: > > Which doesn't help us much... > > What why do you need that vector? I guess I don't ;-) Angus namespace { template void clearIfNotFound(T & data, Enum value, vector

Re: C++ question

2003-09-24 Thread Andre Poenitz
On Wed, Sep 24, 2003 at 02:29:44PM +, Angus Leeming wrote: > Which doesn't help us much... What why do you need that vector? 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...)

Re: C++ question

2003-09-24 Thread Angus Leeming
Andre Poenitz wrote: > On Wed, Sep 24, 2003 at 01:55:09PM +, Angus Leeming wrote: >> Given an enum, is there a semi-automated way of returning a vector of >> all named enum values? The best I can come up with is this: > > None that I am aware of. > > Actually, your solution does not work for

Re: C++ question

2003-09-24 Thread Andre Poenitz
On Wed, Sep 24, 2003 at 01:55:09PM +, Angus Leeming wrote: > Given an enum, is there a semi-automated way of returning a vector of all > named enum values? The best I can come up with is this: None that I am aware of. Actually, your solution does not work for e.g. enum TransformID {

C++ question

2003-09-24 Thread Angus Leeming
Given an enum, is there a semi-automated way of returning a vector of all named enum values? The best I can come up with is this: #include #include template std::vector const all_values_if_consecutive(Enum first, Enum last) { std::vector vals(last - first + 1); typename std::ve

Re: C++ question

2003-06-12 Thread Andre Poenitz
On Thu, Jun 12, 2003 at 09:02:20AM +, Angus Leeming wrote: > Andre Poenitz wrote: > > The generated once will call the cctor and operator= of the base "once" *sigh* I really wonder why people write "phonetically"... Does that mean we think, formulate audible words and write them down using s

Re: C++ question

2003-06-12 Thread Angus Leeming
Andre Poenitz wrote: > On Wed, Jun 11, 2003 at 07:29:17PM +, Angus Leeming wrote: >> class Derived : public Base { >> ??? >> }; >> >> The question is, do I need to define explicit copy c-tor and operator= >> for Derived to ensure that Base's copy c-tor, operator= is used? > > No. >

Re: C++ question

2003-06-12 Thread Andre Poenitz
On Wed, Jun 11, 2003 at 07:29:17PM +, Angus Leeming wrote: > class Derived : public Base { > ??? > }; > > The question is, do I need to define explicit copy c-tor and operator= for > Derived to ensure that Base's copy c-tor, operator= is used? No. The generated once will call the c

C++ question

2003-06-11 Thread Angus Leeming
Suppose I have classes class Base { public: Base() : cache_(0) {} // cache is not copied. Base(Base const &) : cache_(0) {} Base & operator=(Base const &) { return *this; } private:

Re: C++ question

2003-02-14 Thread Andre Poenitz
On Fri, Feb 14, 2003 at 01:43:50PM +, Angus Leeming wrote: > why does this compile: > string data = ...; > istringstream datastream(data); > LyXLex lex(0,0); > lex.setStream(datastream); > > and this not: > LyXLex lex(0,0); > lex.setStream(istri

C++ question

2003-02-14 Thread Angus Leeming
André, as our resident c++ guru, why does this compile: string data = ...; istringstream datastream(data); LyXLex lex(0,0); lex.setStream(datastream); and this not: LyXLex lex(0,0); lex.setStream(istringstream(data)); The compiler complains that it

Re: C++ question

2002-10-31 Thread Andre Poenitz
> I read the recent thread about casting Insets up to > their "real" type and thought I'd try and implement André's > asAInset, asBInset, asCInset thing using templates. > > Unfortunately, it doesn't compile :-( > > Is their anyway to do this? No, you can't have templated virtual member functions.

Re: C++ question

2002-10-31 Thread Angus Leeming
On Thursday 31 October 2002 11:21 am, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | On Thursday 31 October 2002 10:57 am, Lars Gullik Bjønnes wrote: > >> Angus Leeming <[EMAIL PROTECTED]> writes: > >> | I read the recent thread about casting Insets up to > >> | their "r

Re: C++ question

2002-10-31 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | Anyway, to answer your call for testers, this is what happens here: I just tested with gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) this does not have member templates, but dynamic_cast work as expected. To me this implies that all g

Re: C++ question

2002-10-31 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | On Thursday 31 October 2002 10:57 am, Lars Gullik Bjønnes wrote: >> Angus Leeming <[EMAIL PROTECTED]> writes: >> | I read the recent thread about casting Insets up to >> | their "real" type and thought I'd try and implement André's >> | asAInset, asBInse

Re: C++ question

2002-10-31 Thread Angus Leeming
On Thursday 31 October 2002 10:57 am, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | I read the recent thread about casting Insets up to > | their "real" type and thought I'd try and implement André's > | asAInset, asBInset, asCInset thing using templates. > | > | Unfort

Re: C++ question

2002-10-31 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | I read the recent thread about casting Insets up to | their "real" type and thought I'd try and implement André's | asAInset, asBInset, asCInset thing using templates. > | Unfortunately, it doesn't compile :-( > | Is their anyway to do this? Yes, by u

C++ question

2002-10-31 Thread Angus Leeming
I read the recent thread about casting Insets up to their "real" type and thought I'd try and implement André's asAInset, asBInset, asCInset thing using templates. Unfortunately, it doesn't compile :-( Is their anyway to do this? Angus class Base { public: virtual ~Base() {}

Re: C++ question

2002-07-22 Thread John Levon
On Mon, Jul 22, 2002 at 12:35:33PM +0200, Lars Gullik Bjønnes wrote: > You could do as they do in the stl and take a reference are, but store > the pointer. We should probably introduce a new smartpointer for that > then. > > held_ptr<> perhaps. I like this (though it still means I have to have

Re: C++ question

2002-07-22 Thread Lars Gullik Bjønnes
John Levon <[EMAIL PROTECTED]> writes: | What is the standard way to get around the icky std::map requirement | that the value object have a default ctor ? This is forcing me to not | only havea pointless default no-argument ctor, but stop using references | in the struct value for no good reason

C++ question

2002-07-21 Thread John Levon
What is the standard way to get around the icky std::map requirement that the value object have a default ctor ? This is forcing me to not only havea pointless default no-argument ctor, but stop using references in the struct value for no good reason :( regards john -- "Of all manifestations

Re: C++ question

2002-04-26 Thread Andre Poenitz
On Thu, Apr 25, 2002 at 04:02:04PM +0200, Lars Gullik Bjønnes wrote: > outside foo > outside foo inside anon namespace > inside foo... > > but there is one variant that is not allowed... If there is one it might be the one in anon namespace. Reasoning along the lines of: Suppose we had a compil

Re: C++ question

2002-04-25 Thread Lars Gullik Bjønnes
[EMAIL PROTECTED] (Lars Gullik Bjønnes) writes: | | if (it == end) { | | std::cout << c << " not found" << std::endl; | | } else { | | std::cout << c << " found at pos " | | << it - b

Re: C++ question

2002-04-25 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | #include | #include | #include > | using std::string; > | class Foo { | public: | class Functor { | public: | Functor(char cin) : c(cin) {} | bool operator()(char comp) { return c == comp; } | p

Re: Off topic C++ question

2002-04-25 Thread Angus Leeming
On Thursday 25 April 2002 3:04 pm, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | Apologies for the off-topic nature, but you're the best C++ programmers I > | know ;-) > | > | Boost has shared_ptr and shared_c_ptr and scoped_ptr but no scoped_c_ptr > | which leads to t

Re: Off topic C++ question

2002-04-25 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | Apologies for the off-topic nature, but you're the best C++ programmers I | know ;-) > | Boost has shared_ptr and shared_c_ptr and scoped_ptr but no scoped_c_ptr | which leads to the thought that actually all these are the same, save for the | functi

Off topic C++ question

2002-04-25 Thread Angus Leeming
Apologies for the off-topic nature, but you're the best C++ programmers I know ;-) Boost has shared_ptr and shared_c_ptr and scoped_ptr but no scoped_c_ptr which leads to the thought that actually all these are the same, save for the function they call in their d-tor. So why don't they parame

Re: C++ question

2002-04-25 Thread Angus Leeming
On Thursday 25 April 2002 12:48 pm, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > >> class Foo { > >> class Functor {}; > >> > >> void do_stuff() { > >>find_if(..., Functor()); > >> } > >> }; > | > | I'm hazy about why not. Because it can go

Re: C++ question

2002-04-25 Thread Lars Gullik Bjønnes
Andre Poenitz <[EMAIL PROTECTED]> writes: | On Thu, Apr 25, 2002 at 01:40:05PM +0200, Lars Gullik Bjønnes wrote: >> What's not ok is using local classes for this: > | Is this written somewhere? Yes, I belive so. I have seen references to this both at the boost list and comp.lang.c++.moderated.

Re: C++ question

2002-04-25 Thread Andre Poenitz
On Thu, Apr 25, 2002 at 01:40:05PM +0200, Lars Gullik Bjønnes wrote: > What's not ok is using local classes for this: Is this written somewhere? Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)

Re: C++ question

2002-04-25 Thread Andre Poenitz
On Thu, Apr 25, 2002 at 12:35:11PM +0100, Angus Leeming wrote: > What's the official take on putting functors in namespace anon and then > passing them to an STL routine? That's not forbidden as far as I know. But I am not really sure. Andre' -- Those who desire to give up Freedom in order to

Re: C++ question

2002-04-25 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: >> class Foo { >> class Functor {}; >> >> void do_stuff() { >>find_if(..., Functor()); >> } >> }; > | I'm hazy about why not. Because it can go out of scope? See, hazy! Could you | lift my fog? I am not really sure, but jus

Re: C++ question

2002-04-25 Thread Angus Leeming
On Thursday 25 April 2002 12:40 pm, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | What's the official take on putting functors in namespace anon and then > | passing them to an STL routine? > | > | Here, I get warnings like: > | cxx: Warning: /usr/include/cxx/algorithm

Re: C++ question

2002-04-25 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | What's the official take on putting functors in namespace anon and then | passing them to an STL routine? > | Here, I get warnings like: | cxx: Warning: /usr/include/cxx/algorithm.cc, line 110: #1115-D external | routine | uses unnamed type

C++ question

2002-04-25 Thread Angus Leeming
What's the official take on putting functors in namespace anon and then passing them to an STL routine? Here, I get warnings like: cxx: Warning: /usr/include/cxx/algorithm.cc, line 110: #1115-D external routine uses unnamed type or namespace. InputIterator find_if (InputIterator first

Re: C++ question

2002-04-18 Thread Angus Leeming
On Thursday 18 April 2002 10:18 am, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | Do you have any opinions about which way I should go? > > No, not really. > > - be as const as possible > - all class functions that are logically const should be const. > > That's the ru

Re: C++ question

2002-04-18 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | Do you have any opinions about which way I should go? No, not really. - be as const as possible - all class functions that are logically const should be const. That's the rules I use. -- Lgb

Re: C++ question

2002-04-18 Thread Angus Leeming
On Wednesday 17 April 2002 8:21 pm, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > | I'm clearly confused when it comes to "const" and member pointers. > | > | See the little code snippet below. If I compile it, I get the error: > | > | cxx: Error: trial.C, line 23: (that

Re: C++ question

2002-04-17 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | I'm clearly confused when it comes to "const" and member pointers. > | See the little code snippet below. If I compile it, I get the error: > | cxx: Error: trial.C, line 23: (that is, in the const_method) | the object has type qualifiers that are not co

C++ question

2002-04-17 Thread Angus Leeming
I'm clearly confused when it comes to "const" and member pointers. See the little code snippet below. If I compile it, I get the error: cxx: Error: trial.C, line 23: (that is, in the const_method) the object has type qualifiers that are not compatible with the member function func(ob())

Re: C++ question

2002-03-13 Thread Angus Leeming
On Wednesday 13 March 2002 6:08 pm, Lars Gullik Bjønnes wrote: > Angus Leeming <[EMAIL PROTECTED]> writes: > > | If I have a map some_map, can I create a vector of the keys also, > | vector ref_vec? I can create a vector ptr_vec. > > > | I'm thinking of my Bibtex data base of course. > > You c

Re: C++ question

2002-03-13 Thread Lars Gullik Bjønnes
Angus Leeming <[EMAIL PROTECTED]> writes: | If I have a map some_map, can I create a vector of the keys also, | vector ref_vec? I can create a vector ptr_vec. > | I'm thinking of my Bibtex data base of course. You cannot "reset" an reference; string a("Hello There!"); string & b = a; string c(

C++ question

2002-03-13 Thread Angus Leeming
If I have a map some_map, can I create a vector of the keys also, vector ref_vec? I can create a vector ptr_vec. I'm thinking of my Bibtex data base of course. /** All Bibliography keys derive from this base class, and need only define * code() to be instantiated. */ class BibKey { public:

Re: C++ question

2001-12-12 Thread Angus Leeming
On Wednesday 12 December 2001 5:37 pm, Andre Poenitz wrote: > On Wed, Dec 12, 2001 at 03:50:46PM +, Angus Leeming wrote: > > Sorry for the off-topic question but: > > > > What is the correct way to empty a stringstream to use it again? Currently, > > I'm using ss.str(string()) but I'm sure

Re: C++ question

2001-12-12 Thread Andre Poenitz
On Wed, Dec 12, 2001 at 03:50:46PM +, Angus Leeming wrote: > Sorry for the off-topic question but: > > What is the correct way to empty a stringstream to use it again? Currently, > I'm using ss.str(string()) but I'm sure there must be a better way... Don't do that. Use a new stream. I'll ne

Re: C++ question

2001-12-12 Thread Angus Leeming
On Wednesday 12 December 2001 3:52 pm, Lars Gullik Bjønnes wrote: > I do not think there is better way... Thank you. A

C++ question

2001-12-12 Thread Angus Leeming
Sorry for the off-topic question but: What is the correct way to empty a stringstream to use it again? Currently, I'm using ss.str(string()) but I'm sure there must be a better way... std::stringstream ss; // fill it the first time ss << "attempt 1"; std::cerr <

Re: isBuilt isBroken (C++ question)

2001-08-28 Thread Angus Leeming
On Saturday 25 August 2001 21:56, John Levon wrote: > Angus recently added isBuilt() in controllers/ to make sure that > the dialog is built before changing its readonly stuff. > > 60 template > 61 void ControlDialog::show() > 62 { > 63 if (isBufferDependent() && !lv_

Re: isBuilt isBroken (C++ question)

2001-08-27 Thread Yves Bastide
On Mon, Aug 27, 2001 at 08:21:50AM +0200, Andre Poenitz wrote: > > 60 template > > 61 void ControlDialog::show() > > 62 { > > 63 if (isBufferDependent() && !lv_.view()->available()) > > 64 return; > > 65 > > 66 setParams(); > >

Re: isBuilt isBroken (C++ question)

2001-08-27 Thread John Levon
On Mon, Aug 27, 2001 at 08:21:50AM +0200, Andre Poenitz wrote: > I'd say every instance of the function should have its own static. How else > could it work when the type of 'isBuilt' depents on the template parameter? I have no idea - let me put it this way; making it a member fixes the problem

Re: isBuilt isBroken (C++ question)

2001-08-26 Thread Andre Poenitz
> 60 template > 61 void ControlDialog::show() > 62 { > 63 if (isBufferDependent() && !lv_.view()->available()) > 64 return; > 65 > 66 setParams(); > 67 > 68 static bool isBuilt = false; > 69 if (!isB

Re: isBuilt isBroken (C++ question)

2001-08-26 Thread John Levon
On Sun, Aug 26, 2001 at 04:42:03PM +0200, Yves Bastide wrote: > Your void ControlDialog::show() is common to all objects of type > "Base". Why don't you just use a data member? Rough draft: yes, this is what I did in the end. thanks john -- "That's just kitten-eating wrong." - Rich

Re: isBuilt isBroken (C++ question)

2001-08-26 Thread Yves Bastide
On Sat, Aug 25, 2001 at 09:56:49PM +0100, John Levon wrote: > > Angus recently added isBuilt() in controllers/ to make sure that > the dialog is built before changing its readonly stuff. > > 60 template > 61 void ControlDialog::show() > 62 { > 63 if (isBufferDependen

isBuilt isBroken (C++ question)

2001-08-25 Thread John Levon
Angus recently added isBuilt() in controllers/ to make sure that the dialog is built before changing its readonly stuff. 60 template 61 void ControlDialog::show() 62 { 63 if (isBufferDependent() && !lv_.view()->available()) 64 return; 65

Re: C++ question

2001-05-09 Thread Angus Leeming
Perfect. Thank you. A On Wednesday 09 May 2001 11:31, John Levon wrote: > On Wed, 9 May 2001, Angus Leeming wrote: > > > This one dies with > > > > cxx: Error: #79 expected a type specifier > > typedef MenuList::const_iterator const_iterator; > ^ > > try adding "typen

  1   2   >