Macro style templating

Run Settings
LanguageC++
Language Version
Run Command
#include <stdio.h> #define CONCAT_(a,b) a##b #define CONCAT(a,b) CONCAT_(a,b) #define TO_STRING_(a) #a #define TO_STRING(a) TO_STRING_(a) #define VAR_FILE "implementation_file.cpp" // file to be included by all number types #include "number_types.cpp" // number types #undef VAR_FILE int main() { test(32); test(32.0f); test(32.0); return 0; }
#define VAR_TYPE float #define VAR_NAME float #define VAR_PRINT "%f" #include VAR_FILE #define VAR_TYPE double #define VAR_NAME double #define VAR_PRINT "%f" #include VAR_FILE #define VAR_TYPE int #define VAR_NAME int #define VAR_PRINT "%i" #include VAR_FILE
void test(VAR_TYPE a) { printf(TO_STRING(VAR_NAME) ": "VAR_PRINT"\n", a); } #undef VAR_TYPE #undef VAR_NAME #undef VAR_PRINT
Editor Settings
Theme
Key bindings
Full width
Lines