Created
May 14, 2020 06:23
-
-
Save gopi487krishna/329eba5c747b723fee15311b4b39ac82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This is a pretty easy task. | |
Define a structure ( well this is called a trait ) called is_same inside a namespace gstd that returns true if the types | |
passed are same and false if types are different | |
prerequisites | |
* Templates in C++ | |
* Specialization of Templates | |
* Partial Specialization of Templates | |
As you guys are probably new to template meta programming i suggest you to exectute your code here | |
https://cppinsights.io/ | |
**/ | |
namespace gstd{ | |
// Holder template | |
template<typename T,typename U> | |
struct is_same; | |
} | |
/** | |
* Example | |
* bool both_types_same = gstd::is_same<int,int>; //Should return true | |
* bool both_types_same = gstd::is_same<int,float>; // Should return false | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment