Skip to content

Instantly share code, notes, and snippets.

@RedBeard0531
Created November 7, 2019 13:39
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 RedBeard0531/9fe4f1d653fea826db02883d1337ec51 to your computer and use it in GitHub Desktop.
Save RedBeard0531/9fe4f1d653fea826db02883d1337ec51 to your computer and use it in GitHub Desktop.
module reachability examples
export module quux;
export struct quux{};
///////////
// bar.h
import quux
/////////
export module foo;
export struct foo{};
////////
module A:C;
struct C {};
///////
// header_unit.h
struct HU {};
//////
module;
#include "bar.h" // imports quux
export module A:B;
import foo;
import :C;
//////
export module A;
export import :B; // does this import foo? quux? A:C?
import "header_unit.h;
export quux b; // legal? (is today (maybe), 1 makes it not)
export foo f; // legal? (is today, 2 make it not)
export C getC() { return {}; } // legal? (is today, 3 makes it not)
export HU hu;
//////
import A; // A:C is not "necessarily reachable"
C names_c; // Clearly illegal
auto& c_ref = getC(); // Clearly legal
auto c_copy = getC(); // Should this be legal? (unspecified today, 4 makes it legal)
auto& hu_ref = hu; // Clearly legal
auto hu_copy = hu; // Should this be legal? (unspecified today, 4 makes it legal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment