Checking if input is a string or an integer
This is now a conflict:

using namespace std;

//Workaround for compiler issue.
int stoi( const std::string&amp; str, std::size_t* pos = 0, int base = 10 )


There is an stoi in the standard namespace. Because you used using this will be considered with your function. They both have the same parameter types so this should generate a compiler error.

The only reason it may not be doing so is that you are using an archaic version of the language.

You have to reset errno to a zero state before using a function that sets it (std::strtol does not change the value if there is no error it just sets the value if there is an error).

    if( errno == ERANGE || value &gt; std::numeric_limits&lt;int&gt;::max() )
        throw std::out_of_range( "stoi: out ofrange" ) ;


This will fail if a previous library call set errno to ERANGE.

Don't like the extra indention of you r function:

int stoi( const std::string&amp; str, std::size_t* pos = 0, int base = 10 )
    {
^^^^!


Prefer to use {} around block statements.

if( errno == ERANGE || value &gt; std::numeric_limits&lt;int&gt;::max() )
            throw std::out_of_range( "stoi: out ofrange" ) ;

// Best to be safe
// So consistent use of '{}' is usually best.
if( errno == ERANGE || value &gt; std::numeric_limits&lt;int&gt;::max() ) {
            throw std::out_of_range( "stoi: out ofrange" ) ;
}


Readability enhanced by using another line:

if(pos) *pos = end - begin ;

// Easier to read for your next maintainer.
if(pos) {
    *pos = end - begin ;
}