473,395 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Choosing between two functions

I want to choose between using less and less_equal based on a boolean, but I
don't want to type the argument list twice. So I try to do something like the
following:

{
//...
binary_function<Date, Date, bool> &fn(inclusive ? less_equal<Date>()
: less<Date>());
return fn(d1, d2);
}

Assume that d1 and d2 are dates. How would one actually do this, as this causes
a syntax error: Error 1 error C2446: ':' : no conversion from 'std::less<_Ty>'
to 'std::less_equal<_Ty>' c:\docs\wkspc\vs\lab7\lab7\timedevent.cpp 59.

- JFA1
Jul 23 '05 #1
1 1383
James Aguilar wrote:
{
//...
binary_function<Date, Date, bool> &fn(inclusive ? less_equal<Date>()
: less<Date>());
return fn(d1, d2);
}

Assume that d1 and d2 are dates. How would one actually do this, as this causes
a syntax error: Error 1 error C2446: ':' : no conversion from 'std::less<_Ty>'
to 'std::less_equal<_Ty>' c:\docs\wkspc\vs\lab7\lab7\timedevent.cpp 59.


{
//...
if (inclusive)
return less_equal<Date>()(d1, d2);
else
return less<Date>()(d1, d2);
}

Or, once you've got an implementation of TR1, like this:

std::tr1::function<bool,Date,Date> fn;
if (inclusive)
fn = less_equal<Date>();
else
fn = less<Date>();
return fn(d1, d2);

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: JaNE | last post by:
hello and please excuse my clumsy english. I'm really fresh in php (just want to make one small script for myself, haven't fount such on net) and now I'm struggling with "calling one file from...
12
by: Deke | last post by:
I will be embarking on a large web project. I am still researching as to which language use - PHP or Perl. Can someone clear up some of the bad publicity with PHP in the links below? They are...
3
by: John Smith | last post by:
How do I choose/find the function that is right for what I want to do. I have been using the phpManual which is one of the reasons I came to PHP. I would like to know how to search for a function...
0
by: Carsten Gehling | last post by:
> -----Oprindelig meddelelse----- > Fra: python-list-admin@python.org > På vegne af David McNab > Sendt: 17. juli 2003 01:32 > Til: python-list@python.org > Emne: Re: Choosing the right...
11
by: Jean de Largentaye | last post by:
Hi, I need to parse a subset of C (a header file), and generate some unit tests for the functions listed in it. I thus need to parse the code, then rewrite function calls with wrong parameters....
4
by: Jonas Hei | last post by:
I need to decided between Standard and Enterprise Edition (Cost is a criteria - but its secondary to performance - <!--and I am not paying for it myself-->) The server spec under consideration:...
2
by: iam247 | last post by:
Hi I have an ASP form which only includes an option list. The list is dynamically created but includes a default value, which is an instruction "Select a group". The code is shown at bottom....
19
by: ballpointpenthief | last post by:
At the moment, I only write functions which accept pointers as arguments in order to change a value, but I've realised it would often be a lot more effiecient to pass a pointer rather than an...
19
by: hansBKK | last post by:
Upfront disclaimer - I am a relative newbie, just starting out learning about PHP, mostly by researching, installing and playing with different scripts. I am looking for a host that will provide...
4
by: ajmastrean | last post by:
Folks, What are the best practices, pros/cons, performance, scalability considerations in choosing the source/type for an object's ObjectDataSource (consider a GridView that needs to display a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.