Skip to content

Instantly share code, notes, and snippets.

@gopi487krishna
Created May 14, 2020 06:23
Show Gist options
  • Save gopi487krishna/329eba5c747b723fee15311b4b39ac82 to your computer and use it in GitHub Desktop.
Save gopi487krishna/329eba5c747b723fee15311b4b39ac82 to your computer and use it in GitHub Desktop.
/**
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