Article View: pl.comp.lang.c
Article #309677std::atomic w Visualu
From: Marcin
Date: Thu, 31 May 2018 15:47
Date: Thu, 31 May 2018 15:47
31 lines
1704 bytes
1704 bytes
Hej,
Ostatnio patrzylem na implementacje std::atomic. Zrobilem sobie taka
strukture:
struct A
{
char c;
int i;
bool operator==(const A &) const { return true; }
};
i atomic do tego:
std::atomic<A> at;
A a, b;
at.compare_exchange_strong(a, b);
Okazuje sie, ze operator== nie jest uzywany. Implementacja wpada w
specjalizacje dla size==8, pobiera adres i porownuje pamiec. Jest to
zgodne z opisem na MSDN-ie:
https://msdn.microsoft.com/en-us/library/hh874651.aspx
"The compare_exchange_weak and compare_exchange_strong member functions
use memcmp to determine whether two Ty values are equal. These functions
will not use a Ty-defined operator==."
Czy to jest ok? Jesli nawet pominiemy operator== to w pamieci pomiedzy
'c' a 'i' sa 3 bajty smieci. Wiec w ogole nie wiadomo co porowna.
Marcin
Technical Details
Message-ID:
<5b101905$0$683$65785112@news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-b-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-b-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail Newsgroups: pl.comp.lang.c X-Mozilla-News-Host: news://news.neostrada.pl:119 From: Marcin <a@a.a> Subject: std::atomic w Visualu Date: Thu, 31 May 2018 17:47:13 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 Lines: 31 Message-ID: <5b101905$0$683$65785112@news.neostrada.pl> Organization: Telekomunikacja Polska NNTP-Posting-Host: 79.186.35.57 X-Trace: 1527781637 unt-rea-a-01.news.neostrada.pl 683 79.186.35.57:50854 X-Complaints-To: abuse@news.neostrada.pl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit