Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
auto_ptr and cast
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Laurent Guéguen  
View profile  
 More options Sep 27 2012, 6:26 am
From: Laurent Guéguen <lau.gueg...@laposte.net>
Date: Thu, 27 Sep 2012 03:26:57 -0700 (PDT)
Local: Thurs, Sep 27 2012 6:26 am
Subject: auto_ptr and cast
Hi,

in bpp-core  OutputStream.h, I added a class to use std::stringstream,
because I needed
a object that knows how to convert the stream in a string. So I added
this code

#include <sstream>
class StdStr :
  public StlOutputStreamWrapper
{
public:
  StdStr(): StlOutputStreamWrapper(new std::ostringstream()){}

  std::string str() const { return dynamic_cast<const
std::ostringstream*>(stream_)->str();}

  ~StdStr() { delete stream_;}

};

It works fine, but I could not use the inheritance from
StlOutputStream in this, because there the stream_ is an
auto_ptr<std::ostream> , and I need something like dynamic_cast and I
could not manage this.

Cheers,
Laurent


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Julien Yann Dutheil  
View profile  
 More options Sep 27 2012, 7:28 am
From: Julien Yann Dutheil <jy.duth...@gmail.com>
Date: Thu, 27 Sep 2012 13:28:19 +0200
Local: Thurs, Sep 27 2012 7:28 am
Subject: Re: [biopp-devel-forum:902] auto_ptr and cast
Hi Laurent,

I am not sure I get your point... ostringstream is a ostream, so you
should be able to use StlOutputStream with it.
Then you should be able to use
dynamic_cast<ostringstream*>(stream_->get()), isn't it?

Cheers,

Julien.

On Thu, Sep 27, 2012 at 12:26 PM, Laurent Guéguen

--
Julien Y. Dutheil, Ph-D
0 (+49) 6421 178 530

§ Max Planck Institute for Terrestrial Microbiology
Department of Organismic Interactions
Marburg -- GERMANY

§ Intitute of Evolutionary Sciences - Montpellier
University of Montpellier 2 -- FRANCE


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Laurent Guéguen  
View profile  
 More options Sep 28 2012, 3:50 am
From: Laurent Guéguen <lau.gueg...@laposte.net>
Date: Fri, 28 Sep 2012 00:50:31 -0700 (PDT)
Local: Fri, Sep 28 2012 3:50 am
Subject: Re: auto_ptr and cast
For this I agree, but the problem is for the constructor, he needs
an auto_ptr<ostream>  which would be the result of a cast
from an auto_ptr<ostringstream>. But I did not find the way to do it

L

On Sep 27, 1:28 pm, Julien Yann Dutheil <jy.duth...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Julien Yann Dutheil  
View profile  
 More options Sep 28 2012, 5:29 am
From: Julien Yann Dutheil <jy.duth...@gmail.com>
Date: Fri, 28 Sep 2012 11:29:37 +0200
Local: Fri, Sep 28 2012 5:29 am
Subject: Re: [biopp-devel-forum:904] Re: auto_ptr and cast
Indeed,

Actually giving an auto_ptr to the constructor might not be a good
idea, I should check that.
Otherwise you should be able to do:
auto_ptr<ostringstream> ptr1 ...
auto_ptr<ostream> ptr2(ptr1.get());
ptr1.release();
and then give ptr2 to the constructor?

J.

On Fri, Sep 28, 2012 at 9:50 AM, Laurent Guéguen

--
Julien Y. Dutheil, Ph-D
0 (+49) 6421 178 530

§ Max Planck Institute for Terrestrial Microbiology
Department of Organismic Interactions
Marburg -- GERMANY

§ Intitute of Evolutionary Sciences - Montpellier
University of Montpellier 2 -- FRANCE


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Laurent Guéguen  
View profile  
 More options Oct 8 2012, 4:58 am
From: Laurent Guéguen <lau.gueg...@laposte.net>
Date: Mon, 8 Oct 2012 01:58:19 -0700 (PDT)
Local: Mon, Oct 8 2012 4:58 am
Subject: Re: [biopp-devel-forum:904] Re: auto_ptr and cast

Perhaps,  but I do not know how to put all this in one constructor line,
since StlOutputStream needs it for its constructor.

I maintain pointer usage up to now.

Cheers,
L


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »