Can you use the standard binders (std::bind2nd) on a functor taking two
different parameter types?
Here's my code now:
template <typename T>
struct compareValString : public std::binary_function
<resources::ScopedType<T>, std::string, bool >
{
typedef typename resources::ScopedType<TST;
inline bool operator()(const ST &v, const std::string &n)
{
return false;
}
};
....
values.erase(std::remove_if(values.begin(), values.end(),
std::bind2nd(compareValString<ResourceType>(), *it)), values.end());
//it is an iterator for a vector of strings. 2 1676
Shawn McGrath wrote:
>
Can you use the standard binders (std::bind2nd) on a functor taking two
different parameter types?
Yes.
Here's my code now:
template <typename T>
struct compareValString : public std::binary_function
<resources::ScopedType<T>, std::string, bool >
{
typedef typename resources::ScopedType<TST;
inline bool operator()(const ST &v, const std::string &n)
{
return false;
}
};
The function should be const. As in:
bool operator()( const ST& v, const std::string& n ) const
...
values.erase(std::remove_if(values.begin(), values.end(),
std::bind2nd(compareValString<ResourceType>(), *it)), values.end());
//it is an iterator for a vector of strings.
"Shawn McGrath" <sh***********@gmail.comwrote:
Can you use the standard binders (std::bind2nd) on a functor taking two
different parameter types?
Yes.
Here's my code now:
template <typename T>
struct compareValString : public std::binary_function
<resources::ScopedType<T>, std::string, bool >
{
typedef typename resources::ScopedType<TST;
inline bool operator()(const ST &v, const std::string &n)
Should be:
inline bool operator()(const ST &v, const std::string &n) const
{
return false;
}
};
...
values.erase(std::remove_if(values.begin(), values.end(),
std::bind2nd(compareValString<ResourceType>(), *it)), values.end());
//it is an iterator for a vector of strings.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alex Vinokur |
last post by:
Functor-parameters in the for_each() and transform() algorithms are passed by value.
Might it make sense to have also algorithms for_each2() and transform2()
which pass Functor-parameters by...
|
by: CoolPint |
last post by:
I am trying to write a generic heapsort (of course as a self-exercise)
with Iterator interface: something like blow....
But I got into trouble finding out the Iterator to the Child node. If...
|
by: Leslaw Bieniasz |
last post by:
Cracow, 20.09.2004
Hello,
I need to implement a library containing a hierarchy of classes
together with some binary operations on objects. To fix attention,
let me assume that it is a...
|
by: Amit |
last post by:
Hello all.
If I want to use an object both as a Functor and also, if I pass a function
pointer, how can it be done ? For instance, I have something like this
template< typename Iter, typename...
|
by: daniel.w.gelder |
last post by:
Hello, I have been trying to write a functor template for a week now
and I'm just having tons of trouble because I don't understand an issue
that I guess is pretty basic to this task.
...
|
by: Peter Olcott |
last post by:
I created an object that requires access to another objects data, yet have found
no good way to pass this data as a parameter because the member function that
requires this data must be a binary...
|
by: aaragon |
last post by:
Hi guys,
Is there a way to return a functor from a recursive call that takes
different paths? Let's say that I have a tree structure like:
root
|
first child ---- nextSibling ----nextSibling...
|
by: Dijkstra |
last post by:
Hi folks!
First, this is the code I'm using to expose the problem:
------------------------------------------------------------------
#include <functional>
#include <string>
#include...
|
by: raylopez99 |
last post by:
I suspect the answer to this question is that it's impossible, but how
do I make the below code work, at the point where it breaks (marked
below). See error CS0411
This is the complete code. ...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |