Click here to Skip to main content
15,887,248 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: template function argument deduce Pin
Stephen Hewitt11-Mar-08 21:39
Stephen Hewitt11-Mar-08 21:39 
GeneralRe: template function argument deduce [modified] Pin
Rajkumar R12-Mar-08 0:02
Rajkumar R12-Mar-08 0:02 
GeneralRe: template function argument deduce Pin
CPallini11-Mar-08 22:29
mveCPallini11-Mar-08 22:29 
GeneralRe: template function argument deduce Pin
Stephen Hewitt11-Mar-08 19:33
Stephen Hewitt11-Mar-08 19:33 
GeneralRe: template function argument deduce Pin
George_George11-Mar-08 19:52
George_George11-Mar-08 19:52 
GeneralRe: template function argument deduce Pin
Stephen Hewitt11-Mar-08 19:55
Stephen Hewitt11-Mar-08 19:55 
GeneralRe: template function argument deduce Pin
George_George11-Mar-08 20:35
George_George11-Mar-08 20:35 
GeneralRe: template function argument deduce Pin
Stephen Hewitt11-Mar-08 21:01
Stephen Hewitt11-Mar-08 21:01 
Try this (it crashes on MSVC6, but I believe it should work on more standard compliant compilers):
// VanillaConsole.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <iostream>
using namespace std;
 
struct Magic
{
	template <typename T>
	operator T() const
	{
		return 0.1234012340123401234;
	}
};
 
int main()
{
	Magic m;
 
	int i = m;
	float f = m;
	double d = m;
 
	cout << "i=" << i << ", f=" << f << ", d=" << d << endl;
 
	return 0;
}


Steve

GeneralRe: template function argument deduce Pin
Stephen Hewitt11-Mar-08 21:13
Stephen Hewitt11-Mar-08 21:13 
GeneralRe: template function argument deduce Pin
George_George11-Mar-08 22:53
George_George11-Mar-08 22:53 
GeneralRe: template function argument deduce Pin
Stephen Hewitt13-Mar-08 13:50
Stephen Hewitt13-Mar-08 13:50 
GeneralRe: template function argument deduce Pin
George_George13-Mar-08 14:56
George_George13-Mar-08 14:56 
QuestionWhat will be the output Pin
KASR111-Mar-08 2:37
KASR111-Mar-08 2:37 
AnswerRe: What will be the output [modified] Pin
Rajkumar R11-Mar-08 2:43
Rajkumar R11-Mar-08 2:43 
GeneralRe: What will be the output Pin
toxcct11-Mar-08 3:41
toxcct11-Mar-08 3:41 
GeneralRe: What will be the output [modified] Pin
Rajkumar R11-Mar-08 3:54
Rajkumar R11-Mar-08 3:54 
GeneralRe: What will be the output Pin
CPallini11-Mar-08 5:27
mveCPallini11-Mar-08 5:27 
AnswerRe: What will be the output Pin
Maximilien11-Mar-08 2:49
Maximilien11-Mar-08 2:49 
AnswerRe: What will be the output Pin
CPallini11-Mar-08 2:52
mveCPallini11-Mar-08 2:52 
AnswerRe: What will be the output Pin
David Crow11-Mar-08 5:30
David Crow11-Mar-08 5:30 
GeneralRe: What will be the output Pin
Dieghito11-Mar-08 6:14
Dieghito11-Mar-08 6:14 
GeneralRe: What will be the output Pin
CPallini11-Mar-08 6:19
mveCPallini11-Mar-08 6:19 
GeneralRe: What will be the output Pin
Dieghito11-Mar-08 6:27
Dieghito11-Mar-08 6:27 
GeneralRe: What will be the output Pin
Maxwell Chen11-Mar-08 6:38
Maxwell Chen11-Mar-08 6:38 
AnswerRe: What will be the output Pin
Rajkumar R11-Mar-08 6:40
Rajkumar R11-Mar-08 6:40 

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.