How to wrap C++ boost::variant in C++/CLI to grant access from .NETHow to use boost::bind in C++/CLI to bind a member of a managed classWrapping boost::function with a C++/CLI class eventP/Invoke or C++/CLI for wrapping a C libraryC++/CLI + Boost + MonoHow do boost::variant and boost::any work?Help with loading a .Net DLL from c++/CliHow do I wrap a C++ interface (abstract class) in C++/CLI?how to turn C++/CLI .Net socket into boost::asio socket?how to turn boost::asio socket into C++/CLI .Net socket?Returning an int array in C++/CLI to c# .NET
Should a grammatical article be a part of a web link anchor
Is it fine to ask this kind of question to the corresponding author of a paper?
Why CMYK & PNG is not possible?
Conveying the idea of " judge a book by its cover" by " juger un livre par sa couverture"
How could "aggressor" pilots fly foreign aircraft without speaking the language?
What kind of tools would be used to carve bone?
Can something have more sugar per 100g than the percentage of sugar that's in it?
Why do English transliterations of Arabic names have so many Qs in them?
What is this plane with its thick cockpit?
Can one use mythology to study the history of a region?
Water Bottle Rocket Thrust - two calculation methods not matching
5v home network
A Society Built Around Theft?
Modify real part and leaves imaginary part unchanged
What do you call the fallacy of thinking that some action A will guarantee some outcome B, when in reality B depends on multiple other conditions?
Why did a young George Washington sign a document admitting to assassinating a French military officer?
Is sleeping on the ground in cold weather better than on an air mattress?
How to discipline overeager engineer
Extra pieces not sure what to do with them
Why is matter-antimatter asymmetry surprising, if asymmetry can be generated by a random walk in which particles go into black holes?
useState hook setter incorrectly overwrites state
How effective are nunchaku as a choking weapon?
How are steel imports supposed to threaten US national security?
Consecutive numbers that are Manhattan distance 3 apart
How to wrap C++ boost::variant in C++/CLI to grant access from .NET
How to use boost::bind in C++/CLI to bind a member of a managed classWrapping boost::function with a C++/CLI class eventP/Invoke or C++/CLI for wrapping a C libraryC++/CLI + Boost + MonoHow do boost::variant and boost::any work?Help with loading a .Net DLL from c++/CliHow do I wrap a C++ interface (abstract class) in C++/CLI?how to turn C++/CLI .Net socket into boost::asio socket?how to turn boost::asio socket into C++/CLI .Net socket?Returning an int array in C++/CLI to c# .NET
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I am wrapping a C++ library to C++/CLI to call the functionality from .Net. The C++ library has a type using command = boost::variant<assignment, identifier, decimal>
and wonder how to wrap it.
I searched the web but couldnt find anything. And idea is appreciated.
c++-cli boost-variant
add a comment
|
I am wrapping a C++ library to C++/CLI to call the functionality from .Net. The C++ library has a type using command = boost::variant<assignment, identifier, decimal>
and wonder how to wrap it.
I searched the web but couldnt find anything. And idea is appreciated.
c++-cli boost-variant
There is no practical way to map .NET generics onto C++ templates. Templates require all type arguments to be known at link-time, .NET generics are instantiated at runtime. You'd have to fumble an enum type in the wrapper's public interface to force the wrapper user to limit himself to the type parameters you are willing to support.
– Hans Passant
Mar 31 at 11:00
Thank you @HansPassant, I did solve the issue like this: For each variant type I have created a managed type and added an appropriate marshal_as function. My variant visitor then converts the native type inside the variant into its managed counterpart. Then I return the managed type as an System::Object handle. The good thing is that it works fine, the bad is that I always have to do typechecks on the managed side... I also thought about your enum idea and I do not see an advantage to use them. Can you please elaborate that?
– codingdave
Apr 3 at 11:42
add a comment
|
I am wrapping a C++ library to C++/CLI to call the functionality from .Net. The C++ library has a type using command = boost::variant<assignment, identifier, decimal>
and wonder how to wrap it.
I searched the web but couldnt find anything. And idea is appreciated.
c++-cli boost-variant
I am wrapping a C++ library to C++/CLI to call the functionality from .Net. The C++ library has a type using command = boost::variant<assignment, identifier, decimal>
and wonder how to wrap it.
I searched the web but couldnt find anything. And idea is appreciated.
c++-cli boost-variant
c++-cli boost-variant
asked Mar 28 at 20:59
codingdavecodingdave
6916 silver badges17 bronze badges
6916 silver badges17 bronze badges
There is no practical way to map .NET generics onto C++ templates. Templates require all type arguments to be known at link-time, .NET generics are instantiated at runtime. You'd have to fumble an enum type in the wrapper's public interface to force the wrapper user to limit himself to the type parameters you are willing to support.
– Hans Passant
Mar 31 at 11:00
Thank you @HansPassant, I did solve the issue like this: For each variant type I have created a managed type and added an appropriate marshal_as function. My variant visitor then converts the native type inside the variant into its managed counterpart. Then I return the managed type as an System::Object handle. The good thing is that it works fine, the bad is that I always have to do typechecks on the managed side... I also thought about your enum idea and I do not see an advantage to use them. Can you please elaborate that?
– codingdave
Apr 3 at 11:42
add a comment
|
There is no practical way to map .NET generics onto C++ templates. Templates require all type arguments to be known at link-time, .NET generics are instantiated at runtime. You'd have to fumble an enum type in the wrapper's public interface to force the wrapper user to limit himself to the type parameters you are willing to support.
– Hans Passant
Mar 31 at 11:00
Thank you @HansPassant, I did solve the issue like this: For each variant type I have created a managed type and added an appropriate marshal_as function. My variant visitor then converts the native type inside the variant into its managed counterpart. Then I return the managed type as an System::Object handle. The good thing is that it works fine, the bad is that I always have to do typechecks on the managed side... I also thought about your enum idea and I do not see an advantage to use them. Can you please elaborate that?
– codingdave
Apr 3 at 11:42
There is no practical way to map .NET generics onto C++ templates. Templates require all type arguments to be known at link-time, .NET generics are instantiated at runtime. You'd have to fumble an enum type in the wrapper's public interface to force the wrapper user to limit himself to the type parameters you are willing to support.
– Hans Passant
Mar 31 at 11:00
There is no practical way to map .NET generics onto C++ templates. Templates require all type arguments to be known at link-time, .NET generics are instantiated at runtime. You'd have to fumble an enum type in the wrapper's public interface to force the wrapper user to limit himself to the type parameters you are willing to support.
– Hans Passant
Mar 31 at 11:00
Thank you @HansPassant, I did solve the issue like this: For each variant type I have created a managed type and added an appropriate marshal_as function. My variant visitor then converts the native type inside the variant into its managed counterpart. Then I return the managed type as an System::Object handle. The good thing is that it works fine, the bad is that I always have to do typechecks on the managed side... I also thought about your enum idea and I do not see an advantage to use them. Can you please elaborate that?
– codingdave
Apr 3 at 11:42
Thank you @HansPassant, I did solve the issue like this: For each variant type I have created a managed type and added an appropriate marshal_as function. My variant visitor then converts the native type inside the variant into its managed counterpart. Then I return the managed type as an System::Object handle. The good thing is that it works fine, the bad is that I always have to do typechecks on the managed side... I also thought about your enum idea and I do not see an advantage to use them. Can you please elaborate that?
– codingdave
Apr 3 at 11:42
add a comment
|
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406776%2fhow-to-wrap-c-boostvariant-in-c-cli-to-grant-access-from-net%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406776%2fhow-to-wrap-c-boostvariant-in-c-cli-to-grant-access-from-net%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
There is no practical way to map .NET generics onto C++ templates. Templates require all type arguments to be known at link-time, .NET generics are instantiated at runtime. You'd have to fumble an enum type in the wrapper's public interface to force the wrapper user to limit himself to the type parameters you are willing to support.
– Hans Passant
Mar 31 at 11:00
Thank you @HansPassant, I did solve the issue like this: For each variant type I have created a managed type and added an appropriate marshal_as function. My variant visitor then converts the native type inside the variant into its managed counterpart. Then I return the managed type as an System::Object handle. The good thing is that it works fine, the bad is that I always have to do typechecks on the managed side... I also thought about your enum idea and I do not see an advantage to use them. Can you please elaborate that?
– codingdave
Apr 3 at 11:42