this is just something that occurered to me and decided to try. Would it be possible/useful to make something like this work?:
I tried and got this error: [plain] error: ambiguous overload for 'operator>>' in 'std::cin >> q'[/plain].
however the >> operator might not accept volatileIt won't. I tried to write into a volatile: [cpp] volatile char exit; std::cin>>exit; // g++ complains here with "error: ambiguous overload for 'operator>>' in 'std::cin >> exit" [/cpp] before trying the atomic approach.
Sergey Kostrov wrote:Not discussion, but friendly comments :D
I see that discussion continues... :)
Sergey Kostrov wrote:Wow, thanks for those tests. Myself, I only tried the second approach, but it's always good to know what works and what not.
Here are a couple of test-cases with a Visual Studio C/C++ compiler ( just for your reference ):
[ Test-case 1 - Compilation Error ]
volatile char chExit1;
std::cin >> chExit1;
Error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'volatile char' (or there is no acceptable conversion)
[ Test-case 2 - Compilation Warning ]
volatile char chExit2;
std::cin >> ( volatile char )chExit2;
Warning C4197: 'volatile char' : top-level volatile in cast is ignored
[ Test-case 3 - Compiled without any Warnings or Errors ]
std::cin >> ( char )chExit3;
[ Test-case 4 - Compiled without any Warnings or Errors ]
std::cin >> ( char & )chExit4;
Sergey Kostrov wrote:Thanks! Same to you!
Merry Christmas, a.c.sant!