Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > const_cast

Reply
Thread Tools

const_cast

 
 
pallav
Guest
Posts: n/a
 
      04-19-2007
vector<TLExpression*> forms;
map<const TLExpression*, bool> stateTable;

for (ExprMap::iterator itr = stateTable.begin(); itr !=
stateTable.end(); ++itr)
forms.push_back(const_cast<TLExpression *>(itr->first));

i'm trying to use the stl::transform to convert the above code. i have

std::transform(stateTable.begin(0, stateTable.end(),
std::back_inserter(forms),
boost::bind(&ExprMap::value_type::first, _1));

however, i get compiler errors with this saying i'm trying to convert
const TLExpresion* to TLExpression*. i'm not sure where/how to cast
in std::transform. where/what/how should i cast?

thanks for your time/help.

 
Reply With Quote
 
 
 
 
Noah Roberts
Guest
Posts: n/a
 
      04-19-2007
pallav wrote:
> vector<TLExpression*> forms;
> map<const TLExpression*, bool> stateTable;
>
> for (ExprMap::iterator itr = stateTable.begin(); itr !=
> stateTable.end(); ++itr)
> forms.push_back(const_cast<TLExpression *>(itr->first));
>
> i'm trying to use the stl::transform to convert the above code. i have
>
> std::transform(stateTable.begin(0, stateTable.end(),
> std::back_inserter(forms),
> boost::bind(&ExprMap::value_type::first, _1));
>
> however, i get compiler errors with this saying i'm trying to convert
> const TLExpresion* to TLExpression*. i'm not sure where/how to cast
> in std::transform. where/what/how should i cast?
>
> thanks for your time/help.
>


Actually, to really help I shouldn't tell you. What you're doing
shouldn't be done.

You will have to write a function that does the cast. There may be some
already in boost.

std::transform(st.begin(), st.end(), std::back_inserter(forms),
bind(cast_f, bind(&ExprMap::value_type::first, _1)));

something along those lines anyway.

have fun.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const_cast question Gajanan Bhat C++ 9 05-05-2004 12:29 PM
const_cast S.Senthilvel C++ 4 01-08-2004 06:59 PM
const_cast<> R. Anbeeswaran C++ 7 11-14-2003 12:15 PM
const_cast question drowned C++ 3 08-04-2003 08:51 AM
[help] const_cast Kaspar Minosiants C++ 2 07-21-2003 12:43 PM



Advertisments