Skip to content

Commit e54f535

Browse files
committed
Add alien_memory<T> aka 'T volatile, see #393 comment thread
The main problem with `volatile` isn't the semantics -- those are are deliberately underspecified, and appropriate for talking about "memory that's outside the C++ program that the compiler can't assume it knows anything about" which is an important low-level concept. The problems with `volatile` are that (a) it's wired into the language as a type qualifier which is undesirable and unnecessary, and (b) the current name is confusing and has baggage and so it should be named something that connotes what it's actually for (and I like "alien" rather than "foreign" because I think "alien" has a better and stronger connotation).
1 parent c72ac86 commit e54f535

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/cpp2util.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,17 @@ inline auto make_args(int argc, char const* const* argv) -> args_t
15151515
}
15161516

15171517

1518+
//-----------------------------------------------------------------------
1519+
//
1520+
// alien_memory: memory typed as T but that is outside C++ and that the
1521+
// compiler may not assume it knows anything at all about
1522+
//
1523+
//-----------------------------------------------------------------------
1524+
//
1525+
template<typename T>
1526+
using alien_memory = T volatile;
1527+
1528+
15181529
//-----------------------------------------------------------------------
15191530
//
15201531
// Speculative: RAII wrapping for the C standard library

0 commit comments

Comments
 (0)