Skip to content

Instantly share code, notes, and snippets.

@mattfysh
Created February 1, 2020 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattfysh/bf9ab0fea139fca0390cffba0c3c5a9b to your computer and use it in GitHub Desktop.
Save mattfysh/bf9ab0fea139fca0390cffba0c3c5a9b to your computer and use it in GitHub Desktop.
Runtime symbols
#include <iostream>
using namespace std;
template<typename T>
T make_symbol(T value, string metadata);
template<typename T>
string get_symbol_for(T value);
void printString(string str) {
cout << str << endl;
string metadata = get_symbol_for(str);
cout << metadata << endl;
}
int main() {
string greeting = make_symbol("hello", "xyz");
printString(greeting);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment