-
November 28th, 2013, 06:53 PM
#16
Re: i'm updating my variant type
Originally Posted by Cambalinho
sorry i want avoid the boost::any i have tested.
But to do anything that you desire you do have to come up with something similar in design to boost::any. Playing simplistic games with a "dumb" type as a void pointer isn't going to accomplish this goal.
Regards,
Paul McKenzie
-
November 29th, 2013, 05:11 AM
#17
Re: i'm updating my variant type
At a high level, could you describe what you are trying to achieve? Some guru's guru may be able to provide guidance on design etc.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 29th, 2013, 02:19 PM
#18
Re: i'm updating my variant type
Originally Posted by 2kaud
At a high level, could you describe what you are trying to achieve? Some guru's guru may be able to provide guidance on design etc.
that my variant accept any type vector\arrays\class names\struct\union\others, and use it directly(i mean just the var name(variant type) in cout) instead use static_cast way. that's why i give up with boost::any.
-
November 29th, 2013, 02:45 PM
#19
Re: i'm updating my variant type
Yes, but why do you want to do this - what are you trying to accomplish? c++ is a typed language.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 29th, 2013, 02:52 PM
#20
Re: i'm updating my variant type
Originally Posted by 2kaud
Yes, but why do you want to do this - what are you trying to accomplish? c++ is a typed language.
yes it is but:
- the void pointer\boost::any needs the static_cast way for used in cout;
- i like be more simple\direct;
- and you know that i need it...
sorry if these don't make sence to some programmers, but i need these new type
-
November 29th, 2013, 04:44 PM
#21
Re: i'm updating my variant type
Originally Posted by Cambalinho
yes it is but:
- the void pointer\boost::any needs the static_cast way for used in cout;
Because that's how C++ works. If what you wanted could be done, don't you think it would have been done already? If you don't like the fact that the user of the void pointer must know before-hand what to convert it to, then choose another language.
I already mentioned to you that there is no way for anyone to know for sure what a void pointer points to, thereby know what type of cast to use. If I give you a void pointer and no other information, you cannot convert it to another type safely unless you also know what it points to. Again, that's how C++ works.
- i like be more simple\direct;
- and you know that i need it...
sorry if these don't make sence to some programmers, but i need these new type
You still didn't answer the question -- why do you need to do this? C++ is not designed to do this, where an "any" type can be passed around and everyone knows what the "any" is really pointing to.
It seems that with all of your posts, including this thread, you're trying to turn C++ into another language instead of actually developing applications using C++.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; November 29th, 2013 at 04:55 PM.
-
November 29th, 2013, 05:15 PM
#22
Re: i'm updating my variant type
you're trying to turn C++ into another language instead of actually developing applications using C++.
IMO he is. He's mentioned his 'new language' from almost his very first post in these forums. I thought he was going to write a compiler/interpreter in c++ for this language. But it seems the plan is to turn c++ itself into this 'language'. I'm not convinced this is possible never mind feasible.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|