title: What in code defines c++ version?
body: <p>I am new to C++.  I compiled some code from boost/asio examples using g++. </p>
  
  <p>I was successful only after using <code>-std=c++14</code> at the g++ command line. 
  I understood then, and I may be wrong, that the boost/asio library uses C++14.</p>
  
  <p>Then I tried to add code for encoding and decoding base64.</p>
  
  <p>And I received a linker error:</p>
  
  <blockquote>
    <p>undefined reference to base64_decode(std::__cxx11:basic.....</p>
  </blockquote>
  
  <p>I understood by the error that I am passing a <code>std:string</code> in C++11 format and the linker does not find a reference in the files of a function that accepts an argument in that format.</p>
  
  <p>But, where in the code can I see which format this method accepts?
  If my code boost/asio have a <code>std::string</code> and I passed it to this function:</p>
  
  <pre><code>std::string base64_decode(std::string const&amp; s)
  </code></pre>
  
  <p>Why does the linker inform me that this parameter is a C++11 <code>std::string</code>?</p>
  
  <p>How does this work?</p>
  
  <p>Where, in the code, is the version of C++ being used?</p>
  
  <p>This is the Base64 file I tried to add:</p>
  
  <pre><code>#ifndef _BASE64_H_
  #define _BASE64_H_
  #include &lt;string&gt;
  std::string base64_encode(unsigned char const* , unsigned int len);
  std::string base64_decode(std::string const&amp; s);
  #endif  
  </code></pre>
  
  <p>And this the cpp file</p>
  
  <pre><code>#include "base64.h"
  
  static const std::string base64_chars = 
               "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
               "abcdefghijklmnopqrstuvwxyz"
               "0123456789+/";
  
  
  static inline bool is_base64(unsigned char c) {
    return (isalnum(c) || (c == '+') || (c == '/'));
  }
  
  std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
    std::string ret;
    int i = 0;
    int j = 0;
    unsigned char char_array_3[3];
    unsigned char char_array_4[4];
  
    while (in_len--) {
      char_array_3[i++] = *(bytes_to_encode++);
      if (i == 3) {
        char_array_4[0] = (char_array_3[0] &amp; 0xfc) &gt;&gt; 2;
        char_array_4[1] = ((char_array_3[0] &amp; 0x03) &lt;&lt; 4) + ((char_array_3[1] &amp; 0xf0) &gt;&gt; 4);
        char_array_4[2] = ((char_array_3[1] &amp; 0x0f) &lt;&lt; 2) + ((char_array_3[2] &amp; 0xc0) &gt;&gt; 6);
        char_array_4[3] = char_array_3[2] &amp; 0x3f;
  
        for(i = 0; (i &lt;4) ; i++)
          ret += base64_chars[char_array_4[i]];
        i = 0;
      }
    }
  
    if (i)
    {
      for(j = i; j &lt; 3; j++)
        char_array_3[j] = '\0';
  
      char_array_4[0] = (char_array_3[0] &amp; 0xfc) &gt;&gt; 2;
      char_array_4[1] = ((char_array_3[0] &amp; 0x03) &lt;&lt; 4) + ((char_array_3[1] &amp; 0xf0) &gt;&gt; 4);
      char_array_4[2] = ((char_array_3[1] &amp; 0x0f) &lt;&lt; 2) + ((char_array_3[2] &amp; 0xc0) &gt;&gt; 6);
      char_array_4[3] = char_array_3[2] &amp; 0x3f;
  
      for (j = 0; (j &lt; i + 1); j++)
        ret += base64_chars[char_array_4[j]];
  
      while((i++ &lt; 3))
        ret += '=';
  
    }
  
    return ret;
  
  }
  
  std::string base64_decode(std::string const&amp; encoded_string) {
    size_t in_len = encoded_string.size();
    size_t i = 0;
    size_t j = 0;
    int in_ = 0;
    unsigned char char_array_4[4], char_array_3[3];
    std::string ret;
  
    while (in_len-- &amp;&amp; ( encoded_string[in_] != '=') &amp;&amp; is_base64(encoded_string[in_])) {
      char_array_4[i++] = encoded_string[in_]; in_++;
      if (i ==4) {
        for (i = 0; i &lt;4; i++)
          char_array_4[i] = static_cast&lt;unsigned char&gt;(base64_chars.find(char_array_4[i]));
  
        char_array_3[0] = (char_array_4[0] &lt;&lt; 2) + ((char_array_4[1] &amp; 0x30) &gt;&gt; 4);
        char_array_3[1] = ((char_array_4[1] &amp; 0xf) &lt;&lt; 4) + ((char_array_4[2] &amp; 0x3c) &gt;&gt; 2);
        char_array_3[2] = ((char_array_4[2] &amp; 0x3) &lt;&lt; 6) + char_array_4[3];
  
        for (i = 0; (i &lt; 3); i++)
          ret += char_array_3[i];
        i = 0;
      }
    }
  
    if (i) {
      for (j = i; j &lt;4; j++)
        char_array_4[j] = 0;
  
      for (j = 0; j &lt;4; j++)
        char_array_4[j] = static_cast&lt;unsigned char&gt;(base64_chars.find(char_array_4[j]));
  
      char_array_3[0] = (char_array_4[0] &lt;&lt; 2) + ((char_array_4[1] &amp; 0x30) &gt;&gt; 4);
      char_array_3[1] = ((char_array_4[1] &amp; 0xf) &lt;&lt; 4) + ((char_array_4[2] &amp; 0x3c) &gt;&gt; 2);
      char_array_3[2] = ((char_array_4[2] &amp; 0x3) &lt;&lt; 6) + char_array_4[3];
  
      for (j = 0; (j &lt; i - 1); j++) ret += char_array_3[j];
    }
  
    return ret;
  }
  </code></pre>