This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
red_color="\033[1;31m" | |
green_color="\033[1;32m" | |
no_color="\033[0m" | |
throw_error() { | |
if [ ! -z "$1" ]; then | |
printf "${red_color}$1${no_color}\n" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For demonstration purposes we move reverse into a separate function | |
// In C++98 - this would make a deep copy then throw the original | |
// In C++11 - It will detect that a temporary is passed. It uses move semantics automatically. | |
// Copies the pointer and takes ownership of the buffer. | |
// Doesn't do a shallow copy or deep copy. | |
// There is no need to implicitly tell the compiler what to do with a temporary data, | |
// it's error prone while the compiler knows | |
// better and the case is very simple for the compiler to detect. | |
// If the user wants, he can tell it explicitly with "string&& s" | |
string reverse_string(string s) { |
NewerOlder