Use move constructor to address core dump. You cannot free a stack object!
Use ternary operator, take that g++!