I'm confused about how to tell apart "lvalue" and "rvalue" in C, and "lvalue", "xvalue", "prvalue" in C++.
I'm thinking about getting the value type by overload in C++.
#include <iostream>
template<typename T>
void value_category(T & var)
{
std::cout << "Left Value" << std::endl;
}
template<typename T>
void value_category(T && var)
{
std::cout << "Right Value" << std::endl;
}
int main(void)
{
int arr1[4];
int arr2[4];
int arr3[4];
int * mat[3] = {arr1, arr2, arr3};
value_category(arr3);
value_category(arr2[3]);
value_category(mat);
value_category(mat[0]);
}
But it only tells whether lvalue or rvalue? Are there other solutions?