- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
this is just something that occurered to me and decided to try. Would it be possible/useful to make something like this work?:
[cpp]
tbb::atomic<char> q;
std::cin>>q;
[/cpp]
I tried and got this error: [plain] error: ambiguous overload for 'operator>>' in 'std::cin >> q'[/plain].
Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Raf, I think you're over-reacting because I also decided to try it,I wasn't the only one then :D Merry Xmas!.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:Not discussion, but friendly comments :DI 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 ]
char chExit3;
std::cin >> ( char )chExit3;[ Test-case 4 - Compiled without any Warnings or Errors ]
char chExit4;
std::cin >> ( char & )chExit4;
Sergey Kostrov wrote:Thanks! Same to you!Merry Christmas, a.c.sant!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page