Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

Value Semantics

void add(int& a, const int&b){
    a+=b;
}
void add2(int& a, const int&b){
   add(a,b);
   add(a,b);
}

int main(){
    int x = 10;
    add2(x,x);
    return x;
}
auto f(const std::vector<int>& vec, class SomeClass& to_fill);
int main()
{
    SomeClass c;
    std::array<int, 4> arr{1,2,3,4};
    f(arr, c);
}
Task f(const std::vector<int>& vec, class SomeClass& to_fill)
{
	co_await resume_on_threadpool();
	// Do some expensive calculations
}
Task<std::unique_ptr<SomeClass>> f(
std::vector<int> vec,
std::unique_ptr<SomeClass>> to_fill
);

About KDAB


2 Comments

13 - May - 2023

Yuri

Task g()
{
    SomeClass c;
    std::array arr{1,2,3,4};
    co_await f(arr, c);
}

13 - May - 2023

Ilya Doroshenko

ver::Action Initialize()
{
    auto g = gfx.Initialize();
    auto a = audio.Initialize("music.ogg"); //g and a are already executed in parallel on background threads
    co_await winrt::when_all(g,a); // we need them to be finished before swapchain creation
    co_await gfx.CreateSwapchain(hwnd); // completely initialized gfx and audio
}