#include <cstdlib>
#include <iostream>
#include <string>

std::string getCommandLineOption(const std::string& commandLine, const std::string& option)
{
    return commandLine + option;
}

template<typename F>
auto
getCommandLineOption(const std::string& commandLine, const std::string& option, F f)
-> decltype(f(getCommandLineOption(commandLine, option).c_str()))
{
    auto result = getCommandLineOption(commandLine, option);
    return result.empty() ? decltype(f(result.c_str())){} : f(result.c_str());
}

int main()
{
    int serialport = getCommandLineOption("4", "2", atoi);
    std::cout << serialport << std::endl;

    return 0;
}
