Created
March 17, 2018 19:14
-
-
Save ssnover/7cf939d0ba56ea7d871994494d1139ea to your computer and use it in GitHub Desktop.
A short example of showing volatile makes my_struct_t a non-literal type.
This file contains hidden or 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
// Put this gist in Matt Godbolt's Compiler Explorer | |
// Compiler: ARM GCC 6.3 | |
// Options: -std=c++14 | |
#include <cstdint> | |
#include <type_traits> | |
typedef struct | |
{ | |
volatile uint32_t variable1; // Remove volatile, and the condition passes | |
uint32_t variable2; | |
} my_struct_t; | |
int main() | |
{ | |
static_assert(std::is_literal_type<my_struct_t>::value, "Not a literal type"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment