Skip to content

Instantly share code, notes, and snippets.

@TheKingOfAtlantis
Last active August 29, 2015 14:28
Show Gist options
  • Select an option

  • Save TheKingOfAtlantis/8bb4dfe579750effa5a3 to your computer and use it in GitHub Desktop.

Select an option

Save TheKingOfAtlantis/8bb4dfe579750effa5a3 to your computer and use it in GitHub Desktop.
A set of constraints which relate to strings
/*******************************************************************************\
* @brief Defines whether a type is a C-style string type
***
* @tparam Type - The type to check
\*******************************************************************************/
template<template Type> struct is_c_string_type
: std::integral_constant<bool,
std::is_same<Type, CString>::value ||
std::is_same<Type, WCString>::value ||
std::is_same<Type, CString16>::value ||
std::is_same<Type, CString32>::value
>
{ };
/*******************************************************************************\
* @brief Defines whether a type is a C++ style string type
***
* @tparam Type - The type to check
\*******************************************************************************/
template<template Type> struct is_cpp_string_type
: std::integral_constant<bool,
std::is_same<Type, String>::value ||
std::is_same<Type, WString>::value ||
std::is_same<Type, String16>::value ||
std::is_same<Type, String32>::value
>
{ };
/*******************************************************************************\
* @brief Defines whether a type is a ostringstream type
***
* @tparam Type - The type to check
\*******************************************************************************/
template<template Type> struct is_ostringstream_type
: std::integral_constant<bool,
std::is_same<Type, OStringStream>::value ||
std::is_same<Type, WOStringStream>::value ||
std::is_same<Type, OStringStream16>::value ||
std::is_same<Type, OStringStream32>::value ||
>
{ };
/*******************************************************************************\
* @brief Defines whether a type is a istringstream type
***
* @tparam Type - The type to check
\*******************************************************************************/
template<template Type> struct is_istringstream_type
: std::integral_constant<bool,
std::is_same<Type, IStringStream>::value ||
std::is_same<Type, WIStringStream>::value ||
std::is_same<Type, IStringStream16>::value ||
std::is_same<Type, IStringStream32>::value ||
>
{ };
/*******************************************************************************\
* @brief Defines whether a type is a streamstring type
***
* @tparam Type - The type to check
\*******************************************************************************/
template<template Type> struct is_iostringstream_type
: std::integral_constant<bool,
std::is_same<Type, StringStream>::value ||
std::is_same<Type, WStringStream>::value ||
std::is_same<Type, StringStream16>::value ||
std::is_same<Type, StringStream32>::value
>
{ };
/*******************************************************************************\
* @brief Defines whether a type is any of the stringstream types (i/o/both) type
***
* @tparam Type - The type to check
\*******************************************************************************/
template<template Type> struct is_stringstream_type
: std::integral_constant<bool,
is_ostringstream_type<Type> ||
is_istringstream_type<Type> ||
is_iostringstream_type<Type>
>
{ };
/*******************************************************************************\
* @brief Defines whether a type is a string type
***
* @tparam Type - The type to check
\*******************************************************************************/
template<typename Type> struct is_string_type
: std::integral_constant<bool,
is_c_string_type<Type> ||
is_cpp_string_type<Type> ||
is_stringstream_type<Type>
>
{ };
/*******************************************************************************\
* @brief Defines whether a type is a ostream type
***
* @tparam Type - The type to check
\*******************************************************************************/
template<typename Type> struct is_ostream_type
: std::integral_constant<bool,
std::is_same<Type, std::basic_ostream<Char> ||
std::is_same<Type, std::basic_ostream<WChar> ||
std::is_same<Type, std::basic_ostream<Char16> ||
std::is_same<Type, std::basic_ostream<Char32>
>
{ };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment