Click here to Skip to main content
15,888,803 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: compile a class Pin
Rajesh R Subramanian27-Jan-10 8:52
professionalRajesh R Subramanian27-Jan-10 8:52 
AnswerRe: compile a class Pin
loyal ginger27-Jan-10 8:53
loyal ginger27-Jan-10 8:53 
QuestionRe: compile a class Pin
mathy27-Jan-10 21:30
mathy27-Jan-10 21:30 
AnswerRe: compile a class Pin
loyal ginger28-Jan-10 1:43
loyal ginger28-Jan-10 1:43 
AnswerRe: compile a class Pin
CPallini27-Jan-10 11:00
mveCPallini27-Jan-10 11:00 
QuestionDLL "organization" ? Pin
Vaclav_27-Jan-10 7:13
Vaclav_27-Jan-10 7:13 
AnswerRe: DLL "organization" ? Pin
Richard MacCutchan27-Jan-10 9:24
mveRichard MacCutchan27-Jan-10 9:24 
QuestionNumeric Template Error C2296 Pin
Skippums27-Jan-10 6:51
Skippums27-Jan-10 6:51 
I have a template that is to be used with numeric binary types, and takes the following form:
template<typename T>
inline T foo(T other) {
    if (std::numeric_limits<T>::is_integer) {
        T rval(5);
        rval |= other; // Error C2296: '|=' : illegal, left operand has type 'double'
        return rval;
    } else {
        return 5 * other;
    }
}
However, as noted in the comment, I get an error when calling the function with T == double. Is there some way to have such a method? I know two approaches that I could use, so I listed them with the associated reasons why I would like to not have to implement them.

Opt 1. Create template specializations for type float, double, and long double. The downside is that this prevents my method from being used in the future when/if the floating point types half (16-bits) or quad (128-bits) are implemented.
Opt 2. Create two different methods, fooInt and fooFloat, and force the user to notify me of the type being used. The only downside here is namespace clutter, so if there isn't some way of implementing foo as I have written it, this is the option I will choose.

Thanks for any assistance,

Sounds like somebody's got a case of the Mondays

-Jeff

AnswerRe: Numeric Template Error C2296 Pin
Richard MacCutchan27-Jan-10 9:14
mveRichard MacCutchan27-Jan-10 9:14 
GeneralRe: Numeric Template Error C2296 Pin
Skippums27-Jan-10 10:15
Skippums27-Jan-10 10:15 
GeneralRe: Numeric Template Error C2296 Pin
Richard MacCutchan27-Jan-10 22:00
mveRichard MacCutchan27-Jan-10 22:00 
GeneralRe: Numeric Template Error C2296 Pin
Skippums28-Jan-10 3:49
Skippums28-Jan-10 3:49 
GeneralRe: Numeric Template Error C2296 Pin
Richard MacCutchan28-Jan-10 5:16
mveRichard MacCutchan28-Jan-10 5:16 
GeneralRe: Numeric Template Error C2296 Pin
Ken Moynihan28-Jun-10 16:41
Ken Moynihan28-Jun-10 16:41 
GeneralRe: Numeric Template Error C2296 Pin
Richard MacCutchan28-Jun-10 21:29
mveRichard MacCutchan28-Jun-10 21:29 
GeneralRe: Numeric Template Error C2296 Pin
kmoy00728-Jun-10 22:46
kmoy00728-Jun-10 22:46 
GeneralRe: Numeric Template Error C2296 Pin
Richard MacCutchan29-Jun-10 1:40
mveRichard MacCutchan29-Jun-10 1:40 
Questionscrolling image using GDI+ under Windows 7 is very slow and flicking Pin
CODEPC27-Jan-10 4:14
CODEPC27-Jan-10 4:14 
AnswerRe: scrolling image using GDI+ under Windows 7 is very slow and flicking Pin
LunaticFringe27-Jan-10 11:08
LunaticFringe27-Jan-10 11:08 
GeneralRe: scrolling image using GDI+ under Windows 7 is very slow and flicking Pin
CODEPC27-Jan-10 12:09
CODEPC27-Jan-10 12:09 
GeneralRe: scrolling image using GDI+ under Windows 7 is very slow and flicking Pin
LunaticFringe27-Jan-10 13:06
LunaticFringe27-Jan-10 13:06 
QuestionClosing a document and leaving the view Pin
maycockt27-Jan-10 3:13
maycockt27-Jan-10 3:13 
AnswerRe: Closing a document and leaving the view Pin
CPallini27-Jan-10 3:30
mveCPallini27-Jan-10 3:30 
GeneralRe: Closing a document and leaving the view [modified] Pin
maycockt27-Jan-10 3:58
maycockt27-Jan-10 3:58 
AnswerRe: Closing a document and leaving the view Pin
krmed27-Jan-10 4:37
krmed27-Jan-10 4:37 

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.