Skip to content

Instantly share code, notes, and snippets.

@markpapadakis
Created November 5, 2013 15:51
Show Gist options
  • Select an option

  • Save markpapadakis/7321148 to your computer and use it in GitHub Desktop.

Select an option

Save markpapadakis/7321148 to your computer and use it in GitHub Desktop.
// Useful for sorting things - e.g TrivialCmp<int>(a, b)
template<typename T>
inline int32_t TrivialCmp(const T a, const T b)
{
if (a < b)
return -1;
else if (a > b)
return 1;
else
return 0;
}
// For passing strings back and forth
// You may also want to define e.g strwithlen8_t, strwithlen16_t (where size denotes type of length)
// as a standard way to reference strings with length
#define STRLEN(p) (sizeof(p)-1)
#define STRWITHLEN(p) (p), (sizeof(p)-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment