Код: Выделить всё
#include
using namespace std;
void getInt(void *v, const double &src) {*static_cast(v) = src; }
void getDouble(void *v, const double &src) {*static_cast(v) = src; }
struct twoInt{int a; int b;};
void getTwoInt(void *v, const double &src)
{
static_cast(v)->a = src;
static_cast(v)->b = static_cast(src*10) % 10;
}
template
void getData(T f, void* val)
{
double dataSource = 2.1;
f(val, dataSource);
}
int main()
{
int valI;
double valD;
twoInt valTwoInt;
getData(getInt, static_cast(&valI));
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79307391/alternative-for-void-pointers-in-modern-c[/url]