Created
April 9, 2021 03:57
-
-
Save tannergooding/6879d8e90b3b4a153f686fa956b040e1 to your computer and use it in GitHub Desktop.
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 "lib.h" | |
#include "common.h" | |
#include <iostream> | |
void thing() | |
{ | |
auto lib_id1 = get_next_lib_id_int32(); | |
auto lib_id2 = get_next_lib_id_size(); | |
auto this_id1 = get_next_id<std::size_t>(); | |
auto this_id2 = get_next_id<std::int32_t>(); | |
std::cout << | |
"lib id1: " << lib_id1 << "\n" << | |
"lib id2: " << lib_id2 << "\n" << | |
"this id1: " << this_id1 << "\n" << | |
"this id2: " << this_id2 << "\n"; | |
} | |
int main() | |
{ | |
thing(); | |
thing(); | |
} |
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 <cstddef> | |
#include <iostream> | |
std::size_t do_thing() | |
{ | |
static std::size_t id; | |
std::cout << "whoa, do_thing has been called!\n"; | |
return id++; | |
} | |
template <typename T> | |
extern std::size_t get_next_id() | |
{ | |
static std::size_t id = do_thing(); | |
return id; | |
} |
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 "common.h" | |
#include "lib.h" | |
std::size_t get_next_lib_id_int32() | |
{ | |
return get_next_id<std::int32_t>(); | |
} | |
std::size_t get_next_lib_id_size() | |
{ | |
return get_next_id<std::size_t>(); | |
} |
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 <cstddef> | |
std::size_t get_next_lib_id_int32(); | |
std::size_t get_next_lib_id_size(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment