Always build in C++11 mode.

Change-Id: Ia25c738f63aee1b70e61f841ff52a151446ac220
Refs: #1930
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
index 24e76e1..54756c7 100755
--- a/.jenkins.d/10-build.sh
+++ b/.jenkins.d/10-build.sh
@@ -2,21 +2,34 @@
 set -x
 set -e
 
-# Cleanup
-sudo ./waf distclean -j1 --color=yes
-
 COVERAGE=$( python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''" )
 
 sudo rm -Rf /usr/local/include/ndn-cxx
 sudo rm -f /usr/local/lib/libndn-cxx*
 sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
 
-# Configure
-CXXFLAGS="-std=c++03 -pedantic -Wall -Wno-long-long -O2 -g -Werror" \
-  ./waf -j1 configure --color=yes --with-tests --without-pch $COVERAGE
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
 
-# Build
-./waf --color=yes -j1
+# Configure/build in debug mode
+./waf -j1 --color=yes configure --with-tests --without-pch --debug
+./waf -j1 --color=yes build
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in optimized mode without tests with precompiled headers
+./waf -j1 --color=yes configure
+./waf -j1 --color=yes build
+
+# Cleanup
+sudo ./waf -j1 --color=yes distclean
+
+# Configure/build in optimized mode
+./waf -j1 --color=yes configure --with-tests --without-pch $COVERAGE
+./waf -j1 --color=yes build
+
+# (tests will be run against optimized version)
 
 # Install
 sudo ./waf -j1 --color=yes install
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 96690b3..c8b11e0 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -4,20 +4,14 @@
 
 def options(opt):
     opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
-                   help='''Compile in debugging mode without all optimizations (-O0)''')
-    opt.add_option('--with-c++11', action='store_true', default=False, dest='use_cxx11',
-                   help='''Use C++ 11 features if available in the compiler''')
+                   help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
 
 def configure(conf):
     areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
-    defaultFlags = []
-
-    if conf.options.use_cxx11:
-        defaultFlags += ['-std=c++0x', '-std=c++11']
-    else:
-        defaultFlags += ['-std=c++03', '-Wno-variadic-macros', '-Wno-c99-extensions']
-
-    defaultFlags += ['-pedantic', '-Wall', '-Wno-long-long', '-Wno-unneeded-internal-declaration']
+    defaultFlags = ['-std=c++0x', '-std=c++11',
+                    '-stdlib=libc++',   # clang on OSX < 10.9 by default uses gcc's
+                                        # libstdc++, which is not C++11 compatible
+                    '-pedantic', '-Wall']
 
     if conf.options.debug:
         conf.define('_DEBUG', 1)
@@ -29,6 +23,7 @@
                          '-Werror',
                          '-Wno-error=deprecated-register',
                          '-Wno-error=maybe-uninitialized', # Bug #1615
+                         '-Wno-error=unneeded-internal-declaration', # Bug #1588
                         ]
         if areCustomCxxflagsPresent:
             missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
@@ -43,12 +38,15 @@
         if not areCustomCxxflagsPresent:
             conf.add_supported_cxxflags(defaultFlags)
 
+    # clang on OSX < 10.9 by default uses gcc's libstdc++, which is not C++11 compatible
+    conf.add_supported_linkflags(['-stdlib=libc++'])
+
 @Configure.conf
 def add_supported_cxxflags(self, cxxflags):
     """
     Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
     """
-    self.start_msg('Checking allowed flags for c++ compiler')
+    self.start_msg('Checking supported CXXFLAGS')
 
     supportedFlags = []
     for flag in cxxflags:
@@ -57,3 +55,18 @@
 
     self.end_msg(' '.join(supportedFlags))
     self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS
+
+@Configure.conf
+def add_supported_linkflags(self, linkflags):
+    """
+    Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
+    """
+    self.start_msg('Checking supported LINKFLAGS')
+
+    supportedFlags = []
+    for flag in linkflags:
+        if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
+            supportedFlags += [flag]
+
+    self.end_msg(' '.join(supportedFlags))
+    self.env.LINKFLAGS = supportedFlags + self.env.LINKFLAGS
diff --git a/src/common.hpp b/src/common.hpp
index e4d66b3..44a0dd8 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -38,46 +38,39 @@
 #define NDN_CXX_PROTECTED_WITH_TESTS_ELSE_PRIVATE private
 #endif
 
-#include <stdint.h>
-#include <stddef.h>
+// require C++11
+#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__)
+#  error "ndn-cxx applications must be compiled using the C++11 standard"
+#endif
+
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <functional>
+#include <limits>
+#include <memory>
+#include <stdexcept>
+#include <string>
 #include <unistd.h>
 
 #if defined(__GNUC__) || defined(__clang__)
-#define DEPRECATED(func) func __attribute__ ((deprecated))
+#  define DEPRECATED(func) func __attribute__ ((deprecated))
 #elif defined(_MSC_VER)
-#define DEPRECATED(func) __declspec(deprecated) func
+#  define DEPRECATED(func) __declspec(deprecated) func
 #else
-#pragma message("DEPRECATED not implemented")
-#define DEPRECATED(func) func
+#  pragma message("DEPRECATED not implemented")
+#  define DEPRECATED(func) func
 #endif
 
 namespace ndn {
 
 const size_t MAX_NDN_PACKET_SIZE = 8800;
 
-} // namespace ndn
-
-#ifdef NDN_CXX_HAVE_CXX11
-
-#if defined(__GNUC__)
-#  if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
-#    error "NDN-CXX library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
-#  endif // !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
-#endif // defined(__GNUC__)
-
-#if defined(__clang__) && __cplusplus < 201103L
-#  error "NDN-CXX library is configured and compiled in C++11 mode, but the current compiler is not C++11 enabled"
-#endif // defined(__clang__) && (__cplusplus < 201103L)
-
-#include <memory>
-#include <functional>
-
-namespace ndn {
-
 namespace ptr_lib = std;
 namespace func_lib = std;
 
 using std::shared_ptr;
+using std::unique_ptr;
 using std::weak_ptr;
 using std::bad_weak_ptr;
 using std::make_shared;
@@ -98,54 +91,16 @@
 using std::placeholders::_7;
 using std::placeholders::_8;
 using std::placeholders::_9;
-
 using std::ref;
 using std::cref;
 
 } // namespace ndn
 
-
-#else
-
-#include <boost/shared_ptr.hpp>
-#include <boost/weak_ptr.hpp>
-#include <boost/enable_shared_from_this.hpp>
-#include <boost/make_shared.hpp>
-
-#include <boost/function.hpp>
-#include <boost/bind.hpp>
+#include <boost/assert.hpp>
+#include <boost/noncopyable.hpp>
 
 namespace ndn {
-
-namespace ptr_lib = boost;
-namespace func_lib = boost;
-
-using boost::shared_ptr;
-using boost::weak_ptr;
-using boost::bad_weak_ptr;
-using boost::make_shared;
-using boost::enable_shared_from_this;
-
-using boost::static_pointer_cast;
-using boost::dynamic_pointer_cast;
-using boost::const_pointer_cast;
-
-using boost::function;
-using boost::bind;
-
-using boost::ref;
-using boost::cref;
-
-} // namespace ndn
-
-#endif // NDN_CXX_HAVE_CXX11
-
-#include <boost/utility.hpp>
-
-namespace ndn {
-
 using boost::noncopyable;
-
 }
 
 #endif // NDN_COMMON_HPP
diff --git a/src/detail/face-impl.hpp b/src/detail/face-impl.hpp
index cd1b3d8..155185d 100644
--- a/src/detail/face-impl.hpp
+++ b/src/detail/face-impl.hpp
@@ -217,12 +217,12 @@
     }
 
     RegisteredPrefix::Unregistrator bindedUnregistrator =
-      bind(unregistrator, m_face.m_nfdController, unregisterParameters, _1, _2,
-           signatureGenerator,
-           m_face.m_nfdController->getDefaultCommandTimeout());
+        ndn::bind(unregistrator, m_face.m_nfdController.get(), unregisterParameters, _1, _2,
+                  signatureGenerator,
+                  m_face.m_nfdController->getDefaultCommandTimeout());
 
     shared_ptr<RegisteredPrefix> prefixToRegister =
-      ndn::make_shared<RegisteredPrefix>(prefix, filter, bindedUnregistrator);
+      make_shared<RegisteredPrefix>(prefix, filter, bindedUnregistrator);
 
     ((*m_face.m_nfdController).*registrator)(registerParameters,
                                              bind(&Impl::afterPrefixRegistered, this,
diff --git a/src/encoding/tlv.hpp b/src/encoding/tlv.hpp
index 0fb4704..d74323b 100644
--- a/src/encoding/tlv.hpp
+++ b/src/encoding/tlv.hpp
@@ -25,6 +25,7 @@
 #include <stdexcept>
 #include <iostream>
 #include <iterator>
+#include <limits>
 
 #include "buffer.hpp"
 #include "endian.hpp"
diff --git a/src/name-component.cpp b/src/name-component.cpp
index 75d9cfa..9c97773 100644
--- a/src/name-component.cpp
+++ b/src/name-component.cpp
@@ -60,7 +60,7 @@
 }
 
 Component::Component(const char* str)
-  : Block(dataBlock(tlv::NameComponent, str, ::strlen(str)))
+  : Block(dataBlock(tlv::NameComponent, str, std::char_traits<char>::length(str)))
 {
 }
 
diff --git a/src/name-component.hpp b/src/name-component.hpp
index ea68084..b8023b1 100644
--- a/src/name-component.hpp
+++ b/src/name-component.hpp
@@ -189,7 +189,7 @@
   static Component
   fromEscapedString(const char* escapedString)
   {
-    return fromEscapedString(escapedString, 0, ::strlen(escapedString));
+    return fromEscapedString(escapedString, 0, std::char_traits<char>::length(escapedString));
   }
 
   /**
diff --git a/src/util/ethernet.cpp b/src/util/ethernet.cpp
index d5eb780..f68a27a 100644
--- a/src/util/ethernet.cpp
+++ b/src/util/ethernet.cpp
@@ -28,6 +28,7 @@
 #include "ethernet.hpp"
 
 #include <stdio.h>
+#include <ostream>
 
 namespace ndn {
 namespace util {
diff --git a/src/util/in-memory-storage.hpp b/src/util/in-memory-storage.hpp
index fb7ddb6..b9fb9da 100644
--- a/src/util/in-memory-storage.hpp
+++ b/src/util/in-memory-storage.hpp
@@ -37,7 +37,6 @@
 
 #include <stack>
 #include <iterator>
-#include <stdexcept>
 
 namespace ndn {
 namespace util {
diff --git a/src/util/io.hpp b/src/util/io.hpp
index 09ed90c..4c7caf9 100644
--- a/src/util/io.hpp
+++ b/src/util/io.hpp
@@ -27,7 +27,6 @@
 #include "../encoding/block.hpp"
 #include "../encoding/buffer-stream.hpp"
 
-#include <string>
 #include <iostream>
 #include <fstream>
 #include "../security/cryptopp.hpp"
diff --git a/tests/unit-tests/test-name.cpp b/tests/unit-tests/test-name.cpp
index 649bd6f..5bc6f6b 100644
--- a/tests/unit-tests/test-name.cpp
+++ b/tests/unit-tests/test-name.cpp
@@ -163,7 +163,8 @@
                                         bind(&name::Component::isSegmentOffset, _1)));
     dataset.push_back(boost::make_tuple(&name::Component::fromVersion,
                                         bind(&name::Component::toVersion, _1),
-                                        bind(&Name::appendVersion, _1, _2),
+                                        bind(static_cast<Name&(Name::*)(uint64_t)>(
+                                               &Name::appendVersion), _1, _2),
                                         Name("/%FD%00%0FB%40"),
                                         1000000,
                                         bind(&name::Component::isVersion, _1)));
@@ -193,7 +194,7 @@
                                         bind(&name::Component::toTimestamp, _1),
                                         bind(&Name::appendTimestamp, _1, _2),
                                         Name("/%FC%00%04%7BE%E3%1B%00%00"),
-                                        (time::getUnixEpoch() + time::days(14600/*40 years*/)),
+                                        time::getUnixEpoch() + time::days(14600/*40 years*/),
                                         bind(&name::Component::isTimestamp, _1)));
   }
 
diff --git a/wscript b/wscript
index 567d97d..7a3e7fc 100644
--- a/wscript
+++ b/wscript
@@ -58,15 +58,6 @@
     conf.check_sqlite3(mandatory=True)
     conf.check_cryptopp(mandatory=True, use='PTHREAD')
 
-    if conf.options.use_cxx11:
-        conf.check(msg='Checking for type std::shared_ptr',
-                   type_name="std::shared_ptr<int>", header_name="memory",
-                   define_name='HAVE_STD_SHARED_PTR', mandatory=True)
-        conf.check(msg='Checking for type std::function',
-                   type_name="std::function<void()>", header_name="functional",
-                   define_name='HAVE_STD_FUNCTION', mandatory=True)
-        conf.define('HAVE_CXX11', 1)
-
     USED_BOOST_LIBS = ['system', 'filesystem', 'date_time', 'iostreams',
                        'regex', 'program_options', 'chrono', 'random']
     if conf.env['WITH_TESTS']: