// callee.m iOS Native(Objective-C) class
@interface NativeType
- (void)method:(int)arg;
@end
@implementation NativeType
// ...
@end
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 <initializer_list> | |
namespace mock { | |
template <class T> | |
struct allocator {}; | |
template <class T> | |
struct char_traits {}; | |
// C++20 https://timsong-cpp.github.io/cppwp/n4861/basic.string | |
template<class charT, class traits = char_traits<charT>, |
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
bool starts_with_utf8bom(std::string_view s) | |
{ | |
constexpr char utf8_bom[3] = { 0xEF, 0xBB, 0xBF }; | |
return s.length() >= 3 && std::equal(utf8_bom, utf8_bom + 3, s.begin()); | |
} | |
std::string& erase_utf8bom(std::string& text) | |
{ | |
if (starts_with_utf8bom(text)) { | |
text.erase(0, 3); |
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 <type_traits> | |
int main() { | |
int x = 42; | |
static_assert(std::is_same_v<decltype( x ), int>); | |
static_assert(std::is_same_v<decltype((x)), int&>); | |
int (y) = 42; // redundant parentheses | |
static_assert(std::is_same_v<decltype( y ), int>); | |
static_assert(std::is_same_v<decltype((y)), int&>); |
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 <memory> | |
#include <vector> | |
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG | |
#include "spdlog/spdlog.h" | |
#include "spdlog/sinks/stdout_color_sinks.h" | |
#include "spdlog/sinks/daily_file_sink.h" | |
#include "spdlog/sinks/rotating_file_sink.h" | |
int main(int argc, char* argv[]) | |
{ |
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
// | |
// requires Micosoft VisualC++ 2019 16.3 Preview 2 that implements P0717R1. | |
// | |
// https://devblogs.microsoft.com/cppblog/c20-concepts-are-here-in-visual-studio-2019-version-16-3/ | |
// https://wg21.link/p0717r1 Semantic constraint matching for concepts | |
#include <type_traits> | |
#if 1 | |
template <class T, class U> | |
concept same_as_impl = std::is_same_v<T, U>; |
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
constraint-expressions: | |
- C1<T>^c && C2<T>^c | |
- C1<T>^d | |
# concept version | |
template <class T> concept C1<T> = true^a; | |
template <class T> concept C2<T> = true^b; | |
normal form of P = true^a ∧ true^b | |
normal form of Q = true^a |
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://github.com/intel/ffmpeg_libyami/blob/master/libavutil/timecode.c | |
*/ | |
inline int av_timecode_init_from_string2(AVTimecode* tc, AVRational rate, const char* str) | |
{ | |
#if 0 | |
return av_timecode_init_from_string(&tc, rate, str, NULL); | |
#else | |
char c; | |
int hh, mm, ss, ff; |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <ctype.h> | |
#include <objc/message.h> | |
SEL sel_propSetter(Class clazz, const char* pname) | |
{ | |
char* attr = property_copyAttributeValue(class_getProperty(clazz, pname), "S"); |
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
#if defined(__clang__) | |
#pragma message "Clang " __VERSION__ | |
#elif defined(__GNUC__) | |
#pragma message "GCC " __VERSION__ | |
#elif defined(_MSC_VER) | |
// https://qiita.com/yumetodo/items/8c112fca0a8e6b47072d | |
#define STR(s) #s | |
#define DUMP(s) #s "=" STR(s) | |
#pragma message ("MSVC " DUMP(_MSC_VER) " " DUMP(_MSC_FULL_VER)) | |
#endif |