Full barrier
P: =p0=\ /----\ /=p1=\ /----\ /=
* * * *
C: ----/ \=c0=/ \----/ \=c1=/ \-
Half barrier
P: p0=\--------/=p1=\--------/=
#include <cassert> | |
#include <concepts> | |
#include <span> | |
#include <tuple> | |
#include <utility> | |
#include <ranges> | |
#if 1 | |
#include <https://raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp> | |
#else | |
#include <mdspan> |
#include <cassert> | |
#include <bit> | |
#include <iostream> | |
#include <utility> | |
#if 1 | |
#include <https://raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp> | |
using std::experimental::mdspan; | |
using std::experimental::dextents; | |
#else | |
#include <mdspan> |
#include <cassert> | |
#include <array> | |
#include <span> | |
#include <type_traits> | |
#if 0 | |
#include <mdspan> | |
#else | |
#include <https://raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp> | |
#endif | |
using namespace std; |
// https://groups.google.com/g/golang-nuts/c/Gze1TRtdLdc/m/RoD2AxssDgAJ | |
// http://svr-pes20-cppmem.cl.cam.ac.uk/cppmem/ | |
int main() { | |
int x = 0; | |
atomic_int int y = 0; | |
{{{ { x = 1; | |
y.store(1); | |
x = 1; | |
y.store(1); } | |
||| { y.load().readsvalue(0); |
Full barrier
P: =p0=\ /----\ /=p1=\ /----\ /=
* * * *
C: ----/ \=c0=/ \----/ \=c1=/ \-
Half barrier
P: p0=\--------/=p1=\--------/=
#include <ctime> | |
#include <chrono> | |
#include <iostream> | |
#include <iomanip> | |
namespace std { | |
// https://timsong-cpp.github.io/cppwp/n4868/time.cal.ymd.nonmembers#14 | |
// "yyyy-mm-dd" | |
inline ostream& operator<<(ostream& os, const chrono::year_month_day& ymd) { |
// requires C++23 or later | |
#include <bit> | |
#include <concepts> | |
template <std::integral T> | |
constexpr T hton(T value) noexcept | |
{ | |
if constexpr (std::endian::native == std::endian::little) { | |
return std::byteswap(value); | |
} else { |
/* | |
* Convert from OpenCV image and write movie with FFmpeg | |
* | |
* Copyright (c) 2021 yohhoy | |
*/ | |
#include <iostream> | |
#include <vector> | |
// FFmpeg | |
extern "C" { | |
#include <libavformat/avformat.h> |
#include <algorithm> | |
#include <iostream> | |
#include <string> | |
#include <string_view> | |
#include <ranges> | |
int main() { | |
std::string_view str = "apple,banana,cinnamon"; | |
for (auto rev_item: str | std::views::reverse | std::views::split(',')) { | |
static_assert( std::ranges::forward_range<decltype(rev_item)>); |
prog.cc: In function 'int main()': | |
prog.cc:6:19: error: no match for 'operator|' (operand types are 'std::forward_list<int, std::allocator<int> >' and 'const std::ranges::views::_Reverse') | |
6 | for (int _: lst | std::views::reverse) {} | |
| ~~~ ^ ~~~~~~~~~~~~~~~~~~~ | |
| | | | |
| | const std::ranges::views::_Reverse | |
| std::forward_list<int, std::allocator<int> > | |
In file included from prog.cc:2: | |
/opt/wandbox/gcc-head/include/c++/12.0.0/ranges:818:7: note: candidate: 'template<class _Lhs, class _Rhs> requires (derived_from<_Lhs, std::ranges::views::__adaptor::_RangeAdaptorClosure>) && (derived_from<_Rhs, std::ranges::views::__adaptor::_RangeAdaptorClosure>) constexpr auto std::ranges::views::__adaptor::operator|(_Lhs, _Rhs)' | |
818 | operator|(_Lhs __lhs, _Rhs __rhs) |