CCCPaste

a17fd1f6c547d

#include <iostream>
#include <type_traits>
#include <random>

#include "func.h"

void NoRefFoo(Counter x) {
std::cout << "No ref func: " << x << '\n';
}

void RefFoo(const Counter& x) {
std::cout << "Ref func: " << x << '\n';
}

int main() {
static_assert(sizeof(Counter) <= 8);
int x = 0;
Counter w(x);
int n; std::cin >> n;
srand(n);
static_assert(!std::is_invocable_v<decltype(NoRefFoo), Counter>);

static_assert(std::is_invocable_v<decltype(RefFoo), Counter>);

static_assert(std::is_invocable_v<decltype(RefFoo), const Counter&>);

std::cout << "All static assertions passed!\n";
RefFoo(w);
x = 19;
int cnt;
do {
cnt = abs(rand()) % 20;
} while(cnt == 0);
for (size_t i = 0; i < cnt; ++i) {
std::cout << w << '\n';
}
std::cout << w << '\n';
x = 38;
std::cout << w << '\n';
return 0;
}