« first day (2844 days earlier)   

10:14 AM
how to use std::apply with member functions?
CSpawner Spawner;
std::apply(&CSpawner::SpawnActors, Spawner, SpawnParams);
i want to apply SpawnParams to the SpawnActors member function inside the spawner object
it says it takes 2 params and here it take 3
https://www.rangakrish.com/index.php/2018/10/14/c17-stdapply-and-stdinvoke/
 
10:28 AM
std::apply(&CSpawner::SpawnActors, std::tuple_cat(std::make_tuple(Spawner), SpawnParams));
error C2672: 'std::apply': no matching overloaded function found
'decltype(auto) std::apply(_Callable &&,_Tuple &&) noexcept(<expr>)': could not deduce template argument for '_Callable'
 
10:39 AM
apply seems to only take 2 arks, the examples with 3 args are exec, right?
so this would be like the examples in the link:

std::apply(&CSpawner::SpawnActors, tuple_cat(make_tuple(Spawner,) SpawnParams));
but why not just use std::invoke instead, the wrapping in tuples seems useless for this specific case
 
11:30 AM
i get the same error could not deduce template argument for '_Callable'
and this is the line that produce the error std::invoke(&CSpawner::SpawnActors, Spawner, SpawnParams);
error C2672: 'invoke': no matching overloaded function found
note: could be 'unknown-type std::invoke(_Callable &&,_Ty1 &&,_Types2 &&...) noexcept(<expr>)'
note: 'unknown-type std::invoke(_Callable &&,_Ty1 &&,_Types2 &&...) noexcept(<expr>)': could not deduce template argument for '_Callable'
note: or 'unknown-type std::invoke(_Callable &&) noexcept(<expr>)'
note: 'unknown-type std::invoke(_Callable &&) noexcept(<expr>)': expects 1 arguments - 3 provided
 
 
2 hours later…
1:49 PM
@ma1169 The CSpawner is a concrete type, right? And the SpawnActors is just a simple function with no overloads, right?
like CSpawner isn't some incomplete type at the point it's evaulated?
 
 
2 hours later…
4:08 PM
Hello! I hope you are all doing well and happily hacking some C or C++ code!
I need to pad a large amount of image data with all the same RGBA color values. Is there something like memset but for more than one byte? There should be a way to do it without a slow loop but I just cannot find it :(.
 
@Nils the compiler is really good at detecting this and turning it into a memset
 
Last time I checked clang was not.
 
Fill also just accepts one value. I want to put in RGBARGBARGBA, where RGBA stand for 4 different bytes.
 
how are you representing?
struct with four bytes?
pixel quad?
 
4:18 PM
I think there would be 4 options:
* Loop
* Intrinsics
* Pack into an uint32 and then use fill.
* Intrinsics
Yes
 
honestly I would just use an image manip library
 
But I might also have just 3 channels :/
 
hence use an image manip library
that way you're not doing CPU dependent things yourself
 
5:03 PM
the spawner has a couple overloads and it is a complete type at the time of evaluation
I will try mem_fn thanks
 
5:23 PM
@ma1169 you really shouldn't need it unless you're using C++11, you should be able to just use a lambda
that said in all cases make sure that this lives through any execution of the method you're passing around
the traditional way to do that is to use std::make_shared_from_this
lifetime is important!
 
5:44 PM
Thanks, the engine keeps it's objects alive, so life time is not the issue.
the lambda worked fine
 

« first day (2844 days earlier)