Created
March 28, 2017 21:02
-
-
Save greenbagels/cd381e5d9437676382337d96d1495ce3 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
#include <cctype> | |
#include <iostream> | |
#include <type_traits> | |
#include <typeinfo> | |
namespace ascii | |
{ | |
template <typename T, T operand, typename std::enable_if<std::is_same<T,char>::value, int>::type = 0> | |
class get_lower | |
{ | |
public: | |
explicit get_lower() : low_val{operand>='a' ? operand-('a'-'A') : operand} | |
{ | |
} | |
T value() | |
{ | |
return low_val; | |
} | |
private: | |
T low_val; | |
}; | |
} | |
int main() | |
{ | |
ascii::get_lower<char, 'c'> test; | |
std::cout << test.value(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment