473,396 Members | 1,892 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,396 software developers and data experts.

typedef'ing Function Pointers

Hey all,

Another creative question: is it possible to do something like this to type
define a pointer to a specific type of function:

typedef bool (*)(std::string::const_iterator,
std::string::const_iterator) ItCompare;

And if so, how? The above example does not work, btw, I'm just wondering if
there is a way.

- JFA1
Jul 23 '05 #1
3 3897
Try

typedef bool (*ItCompare)
(
std::string::const_iterator,
std::string::const_iterator
);

James Aguilar wrote:
Hey all,

Another creative question: is it possible to do something like this to type
define a pointer to a specific type of function:

typedef bool (*)(std::string::const_iterator,
std::string::const_iterator) ItCompare;

And if so, how? The above example does not work, btw, I'm just wondering if
there is a way.

- JFA1


Jul 23 '05 #2
"James Aguilar" <jf**@cec.wustl.edu> wrote in message
news:d2**********@newsreader.wustl.edu...
Hey all,

Another creative question: is it possible to do something like this to
type define a pointer to a specific type of function:

typedef bool (*)(std::string::const_iterator,
std::string::const_iterator) ItCompare;

And if so, how? The above example does not work, btw, I'm just wondering
if there is a way.


I solved this one on my own just after asking. For those who want to know,
the syntax is like this:

typedef bool (*ItCompare)(std::string::const_iterator,
std::string::const_iterator);
Jul 23 '05 #3
James Aguilar wrote:
Hey all,

Another creative question: is it possible to do something like this to type
define a pointer to a specific type of function:

typedef bool (*)(std::string::const_iterator,
std::string::const_iterator) ItCompare;

And if so, how? The above example does not work, btw, I'm just wondering if
there is a way.

As with other typedefs for pointers to functions, the new type alias
should be together with the *:
typedef bool (*ItCompare)(std::string::const_iterator,
std::string::const_iterator);

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #4

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

Similar topics

1
by: James Aguilar | last post by:
Hey all, I ran into an interesting little problem with defining an iterator in a custom array class the other day. It goes something like this: template <typename T> class Array { public:...
3
by: Generic Usenet Account | last post by:
This is a two-part question. (1) I have implemented a "Datastructure Registry" template class. I am getting no compiler warnings with older compilers, but newer compilers are generating the...
5
by: Cancerbero | last post by:
Hi (first, excuse me for my bad english) As I know, the semantics for typedef is: typedef A B; I think this makes B a synonym of A, where A is an existing data type. Is that right? Based...
2
by: Enrico Porreca | last post by:
Is the following a legal typedef? (gcc -Wall -ansi -pedantic says it's ok) typedef void Callback(void *obj); I mean "a Callback is a function taking void * and returning void" (not "a pointer...
4
by: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= | last post by:
Hello. It's been about a year since I last did some C++ programming. I am now paying the price as I try to catch up with it. The following is the initial snippet of a simple program I am...
13
by: William Xu | last post by:
This won't compile: ,---- | int foo(char *p) | {} | | int main(int argc, char *argv) | { | typedef int (*FUNC)(void *); |
6
Markus
by: Markus | last post by:
Are there any major differences between the following, apart from syntactically: typedef struct { /** Struct members */ } stack; struct sstack { /** Struct members */ } stack;
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...
0
BarryA
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.