today in c++ value category fuckery:
what is the value category of an rvalue reference cast of a function?
@wallhackio what is the answer
@aescling lvalue
@wallhackio i hate c++
@aescling yeah
@wallhackio is there ever a good reason to make such a cast btw
@aescling No. You would just bind the function to a reference or use a lambda, or as a last resort use a function pointer. I cannot imagine a use case for this
@wallhackio Can you give me example of what rvalue reference cast of a function looks like?
@vaporeon_ I've actually never done it before so this'll take me a second haha
#include <iostream>
int add(int a, int b) { return a + b; }
int main() {
// create type alias "AddType" for function of two ints that returns an int
// (this is just C syntax I believe)
typedef int (AddType) (int, int);
AddType&& add_rvalue_ref = (AddType&&)add;
std::cout << add_rvalue_ref(1, 2) << "\n";
}
@vaporeon_ okay, for some reason std::cout << &add_rvalue_ref << "\n";
logs the number 1
to console and compilation gives me the warning "reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]" so um, what the fuck
@wallhackio Wundefined bool conversion
@wallhackio spid-rvalue