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;









1

















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.










share|improve this question


























  • 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


















1

















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.










share|improve this question


























  • 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














1












1








1








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.










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question



share|improve this question










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


















  • 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













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
);



);














draft saved

draft discarded
















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
















draft saved

draft discarded















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript