Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Tricky template non-typeParameter
Tricky template non-typeParameter [message #51822] Sat, 08 June 2019 16:36 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello,

Is it possible to do something like that :

using namespace Upp;

template<dword> struct Type_selector;
template<> struct Type_selector<1> { using Type = int;};
template<> struct Type_selector<3> { using Type = String;};
template<> struct Type_selector<4> { using Type = Date;};
template<> struct Type_selector<134217728> { using Type = long;};
template<> struct Type_selector<134217729> { using Type = float;};
template<> struct Type_selector<2> { using Type = double;};
template<> struct Type_selector<11> { using Type = bool;};

template<dword type> using Type = typename Type_selector<type>::Type;

CONSOLE_APP_MAIN
{
	Type_selector<1>::Type E =1; //work
	Type<1> T =2;//Work
	
	// Is it possible to actually doing something like that :
	Type<"int"> F = 3; //I want F to be Int  from giving Upp::String to 'Type'	
}



thanks in advance

best regard
 
Read Message
Read Message
Previous Topic: Value strange behaviour result in ValueTypeError
Next Topic: What is the difference between learning U++ and Learning C++ through Microsoft Visual Studio?
Goto Forum:
  


Current Time: Fri Apr 26 23:52:58 CEST 2024

Total time taken to generate the page: 0.06985 seconds