Consider the following code:
#include <iostream>
#include <type_traits>
struct type {};
int main(int argc, char* argv[]) {
std::cout << std::is_convertible_v<volatile int, int> << " ";
std::cout << std::is_convertible_v<volatile int, volatile int> << " ";
std::cout << std::is_convertible_v<volatile type, type> << " ";
std::cout << std::is_convertible_v<volatile type, volatile type> << std::endl;
return 0;
}
It prints out
1 1 0 0
Why is volatile int
convertible to int
, but volatile type
is not convertible to type
? Why is a volatile type
not even convertible to volatile type
?
Is there a way to make a volatile
class copyable?
Note: references to the C++ standard are welcome