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
/* | |
Usage: | |
class Test; | |
bool Finalize (); | |
bool Finalize (int i); | |
bool Finalize (int i, int j); | |
{ |
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
template <typename ... Ts> | |
struct ParamPack; | |
template <> | |
struct ParamPack<> { | |
static constexpr size_t count = 0; | |
}; | |
template <typename T, typename ... Ts> | |
struct ParamPack<T, Ts...> { |
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
struct Item { | |
int m_val1; | |
int m_val2; | |
Item (int val1, int val2) { | |
m_val1 = val1; | |
m_val2 = val2; | |
} | |
}; |
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 <mutex> | |
class MySingleton { | |
public: | |
static MySingleton * GetInstance() { | |
std::call_once( | |
m_flag, | |
[] () { m_instance = new MySingleton(); } | |
); | |
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
std::vector<std::string> Tokenize (const std::string & str, char delim) { | |
if (str.empty() || !delim) { | |
return {}; | |
} | |
std::vector<std::string> out; | |
std::string token; | |
std::stringstream ss(str); | |
while (std::getline(ss, token, delim)) { |
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
// | |
// utf8.cpp | |
// | |
// Created by Jinho Bak on 9/30/16. | |
// Copyright (c) 2016 Jinho Bak. All rights reserved. | |
// | |
#include <vector> | |
#include <string> |
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
// for C++14 | |
template <typename E> | |
constexpr auto ToUType(E arg) noexcept | |
{ | |
return static_cast<std::underlying_type_t<E>>(arg); | |
} |
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
// from Effective Modern C++ | |
template <typename T, std::size_t N> | |
constexpr std::size_t arrSize(T (&) [N]) noexcept | |
{ | |
return N; | |
} |
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
/* | |
https://developer.apple.com/library/ios/documentation/GameKit/Reference/GKLocalPlayer_Ref/index.html#//apple_ref/occ/instm/GKLocalPlayer/generateIdentityVerificationSignatureWithCompletionHandler: | |
*/ | |
//////////////////////////////////////////////////////////////////////////////// | |
void GetVerifiedData( | |
std::array<uint8_t, SHA256_DIGEST_LENGTH> & verifiedData, | |
const std::string & playerId, | |
const std::string & bundleId, | |
int64_t timestamp, |
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
template < | |
typename T, | |
typename V = typename std::decay_t<T>::value_type, | |
typename = std::enable_if_t< | |
std::is_base_of<std::basic_string<V>, std::decay_t<T> >::value | |
> | |
> | |
auto GetStringByteSize(const T & str) noexcept | |
{ | |
// ignore null char |
NewerOlder