#include <iostream>
#include <string>
#include <cstdlib>
#define P(x) std::cout<<x<<std::endl

struct Variable                  { void test() { P("variable"); } };
struct Scalar : public Variable  { void test() { P("scalar");   } };
struct Array  : public Variable  { void test() { P("array");    } };

Variable && get(char query)
{
	switch(query)
	{
		case '$': return std::move(Scalar());
		case '@': return std::move(Array());
		
		default: throw 1;
	}
}

int main()
{
	Scalar a = (Scalar&&)get('$');
	Array  b = (Array&&)get('@');
	
	a.test();
	b.test();
}