Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > passing a transform as a function parameter?

Reply
Thread Tools

passing a transform as a function parameter?

 
 
Steven T. Hatton
Guest
Posts: n/a
 
      08-13-2004
If I do:

typedef vector<size_t> v_T;

pair<v_T, v_T> b_T;

b_T bounds(v_T(n), v_T(n)); // if that doesn't work
// std::make_pair(v_T(n), v_T(n));
b_T diff_v(n);
void populate_bounds(&bounds); // all bounds.first[i] <= bounds.second[i]

If I then:

transform(bounds.first.begin(),
bounds.first.end(),
bounds.second.begin(),
diff_v.begin(),
minus<size_t>());

diff_t should get filled with

diff_v[i] == bounds.second[i] - bounds.first[i]

I can then pass diff_v to a function which takes a const &v_T argument. Is
there a way to iliminate diff_v, and simply feed the transform to the
function taking &v_T?

--
STH
Hatton's Law: "There is only One inviolable Law"
KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com
Mozilla: http://www.mozilla.org
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-13-2004
Steven T. Hatton wrote:
> If I do:
>
> typedef vector<size_t> v_T;
>
> pair<v_T, v_T> b_T;


Did you mean

typedef std:air<v_T,v_T> b_T;

?

>
> b_T bounds(v_T(n), v_T(n)); // if that doesn't work
> // std::make_pair(v_T(n), v_T(n));
> b_T diff_v(n);


I don't think you can initialise a pair this way. Did you mean

v_T diff_v(n);

??

> void populate_bounds(&bounds); // all bounds.first[i] <= bounds.second[i]
>
> If I then:
>
> transform(bounds.first.begin(),
> bounds.first.end(),
> bounds.second.begin(),
> diff_v.begin(),
> minus<size_t>());
>
> diff_t should get filled with
>
> diff_v[i] == bounds.second[i] - bounds.first[i]
>
> I can then pass diff_v to a function which takes a const &v_T argument. Is
> there a way to iliminate diff_v, and simply feed the transform to the
> function taking &v_T?


Since you didn't clarify how v_T contains the bounds, I would have to dive
into a pool of assumptions, and it's usually wrong. Perhaps you could be
more specific. Otherwise, the generic answer is, "yes, you can do that,
you only need to correctly define the iterator and the functor".

Victor
 
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
Nokogiri : XSLT Transform passing parameters Une Bévue Ruby 1 01-29-2012 03:15 PM
blocking I/O with javax.xml.parsers.DocumentBuilder.parse() and javax.xml.transform.Transformer.transform() jazzdman@gmail.com Java 1 03-27-2005 06:56 AM
calling VB.net function in a XSL transform amessimon ASP .Net 4 01-05-2005 11:37 AM
Passing a C++ object's member function to a C function expecing a function pointer! James Vanns C++ 7 01-21-2004 02:39 AM
Passing the Functor-parameters in for_each() and transform() Alex Vinokur C++ 5 11-04-2003 04:25 PM



Advertisments