Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #87344
| From | aotto1968 <aotto1968@t-online.de> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | problem with c++ union as argument: |
| Date | 2022-11-13 09:56 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <tkqbg6$1dvjo$1@dont-email.me> (permalink) |
Hi, the following code failed to compile on Create
error: no matching function for call to 'ccmqmsgque::MqMsgqueCallbackC::MqMsgqueCallbackC(const
ccmqmsgque::MqMsgqueCallbackC::MqMsgqueCallbackU&)'
namespace ccmqmsgque {
struct MqMsgqueCallbackC {
enum MqMsgqueCallbackE {
PC_CallbackF,
PC_StaticCallbackF,
PC_IService,
PC_IEvent,
PC_IServerSetup,
PC_IServerCleanup,
PC_IBgError
} type;
union MqMsgqueCallbackU {
MqContextC::CallbackF Callback;
MqContextC::StaticCallbackF StaticCallback;
IService * Service;
IEvent * Event;
IServerSetup * ServerSetup;
IServerCleanup * ServerCleanup;
IBgError * BgError;
} call;
public:
MqMsgqueCallbackC(MqContextC::CallbackF const callback);
MqMsgqueCallbackC(MqContextC::StaticCallbackF const callback);
MqMsgqueCallbackC(IService * const service);
MqMsgqueCallbackC(IEvent * const event);
MqMsgqueCallbackC(IServerSetup * const serverSetup);
MqMsgqueCallbackC(IServerCleanup * const serverCleanup);
MqMsgqueCallbackC(IBgError * const bgError);
MqMsgqueCallbackC(MQ_CTX const context, MqMsgqueCallbackC* const copy);
static MK_CBP Create(const union MqMsgqueCallbackU& callback) {
return (MK_CBP) new MqMsgqueCallbackC(callback);
}
static enum MkErrorE Call ( MQ_CALLBACK_SERVICE_CALL_ARGS );
static void Free ( MQ_RT_ARGS MQ_CTX const context, MK_PTR *dataP);
static void Copy ( MQ_RT_ARGS MQ_CTX const context, MK_PTR *dataP);
};
};
Problem
1. I have a union with all possible argument-types and a CTOR for each type
2. Now I want to have a static "Create" function to call the CTOR for each type
3. I know I could write !! 7 !! "Create", just one for every type BUT I want to
use the union
Question, how I do it?
mfg
AO
Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread
problem with c++ union as argument: aotto1968 <aotto1968@t-online.de> - 2022-11-13 09:56 +0100
Re: problem with c++ union as argument: Bonita Montero <Bonita.Montero@gmail.com> - 2022-11-13 11:05 +0100
Re: problem with c++ union as argument: Marcel Mueller <news.5.maazl@spamgourmet.org> - 2022-11-13 12:48 +0100
Re: problem with c++ union as argument: Michael S <already5chosen@yahoo.com> - 2022-11-13 04:44 -0800
Re: problem with c++ union as argument: Bonita Montero <Bonita.Montero@gmail.com> - 2022-11-13 19:52 +0100
Re: problem with c++ union as argument: Michael S <already5chosen@yahoo.com> - 2022-11-13 04:28 -0800
Re: problem with c++ union as argument: Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-11-13 11:39 -0800
Re: problem with c++ union as argument: Juha Nieminen <nospam@thanks.invalid> - 2022-11-16 09:36 +0000
Re: problem with c++ union as argument: Jorgen Grahn <grahn+nntp@snipabacken.se> - 2022-11-19 22:42 +0000
csiph-web