Skip to content

Instantly share code, notes, and snippets.

@greenbagels
Created March 28, 2017 21:02
Show Gist options
  • Save greenbagels/cd381e5d9437676382337d96d1495ce3 to your computer and use it in GitHub Desktop.
Save greenbagels/cd381e5d9437676382337d96d1495ce3 to your computer and use it in GitHub Desktop.
#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