title: No type named 'function' in namespace std
body: <p>I wanted to pass lambdas around, so I defined a function like this:</p>
  
  <pre><code>double getInput(std::string inputDescription, std::function&lt;bool(double)&gt; isValid) { ... }
  </code></pre>
  
  <p>But gcc refused to compile it. I quickly learned I needed a compiler with C++11 support, so I downloaded clang 3.5 with MacPorts. I located clang++ and confirmed it was the right version (and I wasn't accidentally using the original clang 1.7):</p>
  
  <pre><code>$ /opt/local/bin/clang++ --version
  clang version 3.5.0 (trunk 210448)
  Target: x86_64-apple-darwin10.8.0
  Thread model: posix
  </code></pre>
  
  <p>But even Clang 3.5 gives me:</p>
  
  <pre><code>tempConverter.cpp:14:52: error: no type named 'function' in namespace 'std'
  double getInput(std::string inputDescription, std::function&lt;bool(double)&gt; isValid) {
                                                ~~~~~^
  </code></pre>
  
  <p>The full .cpp file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;iomanip&gt;
  #include &lt;functional&gt;
  #include &lt;string&gt;
  
  static const double minTemp = -273.15;
  static const double maxTemp = 500.0;
  
  inline bool between(double x, double min, double max) {
      return min &lt;= x &amp;&amp; x &lt;= max;
  }
  
  double getInput(std::string inputDescription, std::function&lt;bool(double)&gt; isValid) {
      double input;
      std::cout &lt;&lt; inputDescription &lt;&lt; std::endl;
      std::cin &gt;&gt; input;
  
      while (!isValid(input)) {
          std::cout &lt;&lt; "Invalid input. Please reenter." &lt;&lt; std::endl;
          std::cin &gt;&gt; input;
      }
  
      return input;
      /*double temp1, temp2;
      std::cout &lt;&lt; "Please enter consecutively the upper and lower limits, both between " &lt;&lt;  MIN_TEMP &lt;&lt; " and " &lt;&lt; MAX_TEMP &lt;&lt; "." &lt;&lt; std::endl;
      std::cin &gt;&gt; temp1;
      std::cin &gt;&gt; temp2;
      while (!between(temp1, MAX_TEMP, MIN_TEMP) || !between(temp2, MAX_TEMP, MIN_TEMP)) {
          std::cout &lt;&lt; "At least one of the temperatures is out of bounds. Please reenter:" &lt;&lt; std::endl;
          std::cin &gt;&gt; temp1;
          std::cin &gt;&gt; temp2;
      }
      upper = std::max(temp1, temp2);
      lower = std::min(temp1, temp2);
      std::cout &lt;&lt; "Please enter a positive stepsize, smaller than the difference between the limits." &lt;&lt; std::endl;
      std::cin &gt;&gt; step;
      while (step &lt; 0 || step &gt; upper - lower) {
          std::cout &lt;&lt; "The stepsize is out of bounds. Please reenter:" &lt;&lt; std::endl;
          std::cin &gt;&gt; step;
      }*/
  }
  
  double toFahrenheit(double celsius) {
      return celsius*(9.0/5.0) + 32;
  }
  
  void printTable(double start, double end, double step) {
      std::cout &lt;&lt; std::setw(10) &lt;&lt; "Celsius" &lt;&lt; "|" &lt;&lt; std::setw(10) &lt;&lt; "Fahrenheit" &lt;&lt; std::endl;
      std::cout &lt;&lt; std:setw(10) &lt;&lt; "=======" &lt;&lt; "|" &lt;&lt; std::setw(10) &lt;&lt; "==========" &lt;&lt; std::endl;
      for (double i = start; i &lt; end; i += step) {
          std::cout &lt;&lt; std::setw(10) &lt;&lt; i &lt;&lt; "|" &lt;&lt; std::setw(10) &lt;&lt; toFahrenheit(i) &lt;&lt; std::endl;
      }
  }
  
  int main() {
      double start = getInput("Please enter the upper limit.", [](double x) { return between(x, minTemp, maxTemp); });
      double end = getInput("Please enter the lower limit.", [&amp;](double x) { return x &lt; start &amp;&amp; between(x, minTemp, maxTemp); });
      double step = getInput("Please enter the stepsize.", [&amp;](double x) { return x &lt; end - start &amp;&amp; x &gt; 0; });
      printTable(start, end, step);
  }
  </code></pre>
  
  <p>Is compiled with:</p>
  
  <pre><code>/opt/local/bin/clang++ -std=c++11 tempConverter.cpp -o tempConverter
  </code></pre>