Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:40:55+00:00 2026-06-04T03:40:55+00:00

I couldn’t find anything about this on the Internet, so I’m looking for someone

  • 0

I couldn’t find anything about this on the Internet, so I’m looking for someone with the insights into the way C++/CX is impemented. The Wikipedia article on C++/CX says that it supports runtime-based generics, wich would imply that you don’t need a header file with full implementation in order to instantiate a generic type. I undertand how this works for .NET (assemblies contain IL code and JIT can just insert concrete types into it and compile it whenever there’s a new instantiation), but in C++/CX (which is natively compiled) there is no JIT to edit the code at runtime (which I asume would be pretty hard for x86 machine code)

So what’s the trick here, is it type erasure with boxing or some new contrived scheme?

(I know that the metadata about types is stored in .NET format, I’m after the code in the methods)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:40:57+00:00Added an answer on June 4, 2026 at 3:40 am

    Looking at this article here the reference to generics on the last row specifies that generics are used in C++/CX with interfaces and delegates.

    http://msdn.microsoft.com/en-us/library/windows/apps/br212455(v=vs.110).aspx

    This makes sense because since it is defined as an interface that allows the C++/CX compiler to compile native code functions for the actual objects, and then use generic interfaces in a fashion similar to C++ templates. The native code for the functions is compiled and the generic interface is used to work with the different types.

    For the compiler it seems that this is the difference between C++/CLR and C++/CX.
    /clr: Generics classes, interfaces & delegates allowed.
    /ZW: Generic interfaces & delegates only.

    If you look here http://msdn.microsoft.com/en-us/library/windows/apps/hh699870(v=vs.110).aspx you will notice that there are no generic rules for the classes.

    But if you read this topic http://msdn.microsoft.com/en-us/library/windows/apps/hh755792(v=vs.110).aspx you will notice that the generics are applied as interfaces.

    A “generic class” in C++/CX is achieved by using standard C++ templates. The instantiation or the compiler generated specific type of the generic is exported to the metadata, but not the template itself. Thus you can see a MyClass and a MyClass from the metadata but not the original MyClass. This is not true for the generic interface case which is exported to metadata as a generic type.

    More information on this can be found here http://en.wikipedia.org/wiki/Windows_Runtime

    So to fully answer the question, as of this time, the code in the methods is precompiled native code in the output dll or exe and is attached to actual non generic classes. BUT the code can be used generically by using generic interfaces. So ten different classes can implement IMyInterface and then a variable of type IMyInterface can be used to work with instances of the ten different types for example.

    Thus the short answer is there is nothing like full generic classes in C++/CX as there is in C++/CLR. Use templates for the same effect in C++/CX applications. If you must have C++ generics then use a dll made with C++/CLI and work that code from a program compiled as C++/CX.

    Note! I gleaned this much from examining various articles and some of them at msdn seem to say they might be subject to change.

    Now to use the generic interfaces in C++/CX with templates is probably what they intend. So you make a template called MyClass and then it implements your generic interface called MyInterface, so if you then made a MyClass template instantiation, the new type will automatically implement MyInterface, and this interface can then be used anywhere. So outside of the compiled dll and the header files, other C++/CX modules and files can work with types like MyInterface without needing the header file, because the template instantiation was inside the compiled dll, but a c++ file using the metadata knows how to make the MyInterface type because it has the metadata for MyInterface it, but not the metadata for the MyClass.

    In very short there is no generic classes and the generic interface and delegate support in C++/CX is all that actually works like generics in C++/CLI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Couldn't find anything about this on the internet, or stackoverflow?!? Basic Example: A great
Couldn't find anything about this topic. I have a Windows TCP C++ server application
Couldn't find this anywhere, maybe I'm looking for the wrong verbs. I'm trying to
Couldn't find anything on this with a Google Search. Does anyone know how to
Couldn't find anything relevant in forums So ,Please help me with this code .I'm
I couldn't seem to find a similar question to this. I am currently looking
Couldn't find any documentation about this: what is the order of execution of the
Couldn't find anything quite what I was looking for but if I've missed something
I couldn't find enough resource about this subject and i need to learn how
I couldn't find a suitable title for this. I'm going to express my query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.