Created
November 7, 2019 13:39
-
-
Save RedBeard0531/9fe4f1d653fea826db02883d1337ec51 to your computer and use it in GitHub Desktop.
module reachability examples
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
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