i did the Get macro and works fine:

#define Get(x) [this]()->x

(like you see it's a lambda function header)
but i see 1 problem(sample):

Get(int)

like you see the type is inside of the macro function :(
but i need it:

int Get()

can anyone advice me for do these change?
i use c++ 11

Recommended Answers

All 8 Replies

#define Get(x) int(x)

sorry not that. the 'x' is the type

#define Get(x) typeid(x).name()

if I understood correctly?

i'm sorry AndrisP... i'm sorry my english. but i'm trying :(
my actual macro is:

#define Get(x) [this]()->x

the 'x' is the type. but the Get() returns a 'x' value. so the 'x' must be on back of the Get()(like another functions). but i don't know change that with macros :(

What are you trying to do with this? From what I know about lambda's [this]()->x means: function that captures the this pointer and returns x and has no function body. It would be helpfull to see the use case for your macro. Also are you sure you want to use a macro? Could this be something that's solved with a template? Remember macros are evil.

NathanOliver: in these case must be a macro... at leastt i think ;)
see these propertie sample:

 property <int> Mousehover
        {
            Get(int)
            {
               return intMouseHover;
            },
            Set(int mousehover)
            {
                intMouseHover = mousehover;
            }
        };

like you see the 'int', on 'Get', is like an argument and not like return... but the macro make it like a return value :(
so how can i change that macro for work like a normal function?

OK, so your real goal has to do with implementing a property system in C++, then?

Schol-R-LEA yes;)
my property class works fine. but i only need change the Get() macro nothing more ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.