Click here to Skip to main content
15,909,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralStatusbar update problem Pin
Anonymous12-Nov-02 21:17
Anonymous12-Nov-02 21:17 
Generalproblem with unicode and XML Pin
12-Nov-02 21:04
suss12-Nov-02 21:04 
GeneralRe: problem with unicode and XML Pin
Alois Kraus12-Nov-02 21:47
Alois Kraus12-Nov-02 21:47 
GeneralRe: problem with unicode and XML Pin
Anonymous12-Nov-02 22:47
Anonymous12-Nov-02 22:47 
GeneralRe: problem with unicode and XML Pin
Alois Kraus13-Nov-02 7:06
Alois Kraus13-Nov-02 7:06 
GeneralRe: problem with unicode and XML Pin
Ernesto Perales Soto13-Nov-02 14:03
Ernesto Perales Soto13-Nov-02 14:03 
GeneralCommandBars missing... Pin
Daniel Strigl12-Nov-02 20:38
Daniel Strigl12-Nov-02 20:38 
GeneralInt2Type Generic Programming :: C++ Pin
valikac12-Nov-02 20:34
valikac12-Nov-02 20:34 
The following question relates to a programming technique Andrei Alexandrescu presents in Modern C++ Design. Due to the lack of time, I assume you either have read it or understand the concept via experience.

In his book, Alexandrescu shows a generic programming technique he calls "Mapping Integral Constant to Types" in chapter 2, section 2.4. Here is an example.

-----
template <<int a="">>
struct Int2Type
{
enum {type = A};
};

enum TypeA{WIN = 0x0000, LOSS};

template <<typename t,="" int="" u="">>
class XYZ
{
T *Create(Int2Type<<win>> );
T *Create(Int2Type<<loss>> );
};

// Usage

XYZ<<myclass, win="">> zyx;
-----

Again, I assume you understand the concept above.

XYZ<<myclass, win="">> ... compiles as along as you pass in WIN or LOSS. However, here is what I want to do, but have not been able to get Visual C++ to compile without errors.

-----
TypeA myType;
myType = WIN;

XYZ<<myclass, mytype="">> zyx;
-----

I would like to know if there is a solution to the problem above.

The general idea is I want to pass in WIN or LOSS via a variable. The reason I have not implemented WIN and/or LOSS instead of the variable is because in the way I have setup the algorithm. Typing in WIN and LOSS will require switch states and if/else statements.

Thanks,
Kuphryn
GeneralRe: Int2Type Generic Programming :: C++ Pin
Christian Graus12-Nov-02 20:48
protectorChristian Graus12-Nov-02 20:48 
GeneralRe: Int2Type Generic Programming :: C++ Pin
Joaquín M López Muñoz12-Nov-02 21:49
Joaquín M López Muñoz12-Nov-02 21:49 
GeneralRe: Int2Type Generic Programming :: C++ Pin
valikac13-Nov-02 11:11
valikac13-Nov-02 11:11 
GeneralRe: Int2Type Generic Programming :: C++ Pin
Joaquín M López Muñoz13-Nov-02 11:17
Joaquín M López Muñoz13-Nov-02 11:17 
GeneralRe: Int2Type Generic Programming :: C++ Pin
valikac13-Nov-02 11:29
valikac13-Nov-02 11:29 
GeneralRe: Int2Type Generic Programming :: C++ Pin
Joaquín M López Muñoz13-Nov-02 11:44
Joaquín M López Muñoz13-Nov-02 11:44 
GeneralRe: Int2Type Generic Programming :: C++ Pin
valikac13-Nov-02 12:17
valikac13-Nov-02 12:17 
Questionlightweight replacement for std::vector? Pin
Chris Losinger12-Nov-02 20:12
professionalChris Losinger12-Nov-02 20:12 
AnswerRe: lightweight replacement for std::vector? Pin
Joaquín M López Muñoz12-Nov-02 21:28
Joaquín M López Muñoz12-Nov-02 21:28 
GeneralRe: lightweight replacement for std::vector? Pin
Chris Losinger13-Nov-02 5:13
professionalChris Losinger13-Nov-02 5:13 
AnswerRe: lightweight replacement for std::vector? Pin
peterchen12-Nov-02 23:38
peterchen12-Nov-02 23:38 
GeneralRe: lightweight replacement for std::vector? Pin
Chris Losinger13-Nov-02 5:15
professionalChris Losinger13-Nov-02 5:15 
AnswerRe: lightweight replacement for std::vector? Pin
Tim Smith13-Nov-02 6:20
Tim Smith13-Nov-02 6:20 
QuestionHow to chk dialog instance Pin
Prateeti12-Nov-02 19:48
Prateeti12-Nov-02 19:48 
Generalget 2 menus at same time Pin
includeh1012-Nov-02 18:11
includeh1012-Nov-02 18:11 
GeneralRe: get 2 menus at same time Pin
Maximilien13-Nov-02 3:12
Maximilien13-Nov-02 3:12 
GeneralSetting Color background in CClientDC Pin
WayneJ12-Nov-02 17:45
WayneJ12-Nov-02 17:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.