Add conditional support for C++11 compilers.

This allows madlib to be compiled on OSX with libc++ and
other C++11 compilers.

On OSX, this gets rid of the need to use either an old version
of MacOS (Sierra or earlier), download an old version of
XCode (9.x or earlier), or compile with gcc (the last of which
is unacceptable for a release version, as it means it will not
run on MacOS without the user manually installing 3rd party
libraries).

- CXX11 CMake flag added, which enables support for the C++11
  ABI.

- Code has been updated to meet C++11 standards, but for now,
  changes are hidden behind #if macros, and only become active
  when -DCXX11 is passed.

NOTE:  Old versions of Boost (< 1.65) are incompatible with the
  C++ ABI, including Boost 1.61 which is auto-downloaded by
  madlib if none is found.  Soon we should probably
  download a newer version of Boost if it's not detected and
  CXX11 is enabled.  For now, the user must run "brew install
  boost" if they need CXX11 support.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ea7732..da573e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -122,7 +122,11 @@
         set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
     endif(APPLE)
 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
-    set(CMAKE_CXX_FLAGS "-stdlib=libstdc++")
+if (CXX11)
+    set(CMAKE_CXX_FLAGS "-stdlib=libc++ -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=1")
+else (CXX11)
+    set(CMAKE_CXX_FLAGS "-stdlib=libstdc++ -D_GLIBCXX_USE_CXX11_ABI=0")
+endif(CXX11)
 endif(CMAKE_COMPILER_IS_GNUCXX)
 
 # force a `m4_' prefix to all builtins
diff --git a/ReadMe_Build.txt b/ReadMe_Build.txt
index 2e7b885..583bd40 100644
--- a/ReadMe_Build.txt
+++ b/ReadMe_Build.txt
@@ -179,6 +179,14 @@
     flag is set to 'True', we will create an RPM instead. Note that
     package alien must be installed for this to work.
 
+- `CXX11` (default: *empty*)
+
+    Compile with C++11 compatibility.  This may be required for building
+    on newer platforms which don't come with support for pre-2011 C++
+    standards.  For example, MacOSX >= 10.13 (XCode >= 10.x).  This option
+    is also required for Boost >= 1.65 to work, as recent versions of
+    Boost have also dropped support for older C++ standards.
+
 Debugging
 =========
 
diff --git a/src/dbal/DynamicStruct_impl.hpp b/src/dbal/DynamicStruct_impl.hpp
index 978f138..723b0ff 100644
--- a/src/dbal/DynamicStruct_impl.hpp
+++ b/src/dbal/DynamicStruct_impl.hpp
@@ -425,7 +425,7 @@
     static_cast<Derived*>(this)->bind(inStream);
 
     if (mSizeIsLocked)
-        inStream.template seek(begin + size, std::ios_base::beg);
+        inStream.seek(begin + size, std::ios_base::beg);
     else
         inStream.template seek<ByteStream_type::maximumAlignment>(0,
             std::ios_base::cur);
diff --git a/src/modules/sample/WeightedSample_impl.hpp b/src/modules/sample/WeightedSample_impl.hpp
index 3a04d45..7137b5b 100644
--- a/src/modules/sample/WeightedSample_impl.hpp
+++ b/src/modules/sample/WeightedSample_impl.hpp
@@ -7,6 +7,9 @@
 #ifndef MADLIB_MODULES_SAMPLE_WEIGHTED_SAMPLE_IMPL_HPP
 #define MADLIB_MODULES_SAMPLE_WEIGHTED_SAMPLE_IMPL_HPP
 
+#if _GLIBCXX_USE_CXX11_ABI
+#include <random>
+#else
 #include <boost/tr1/random.hpp>
 
 // Import TR1 names (currently used from boost). This can go away once we make
@@ -14,6 +17,7 @@
 namespace std {
     using tr1::bernoulli_distribution;
 }
+#endif // _GNUCXX_USE_CXX11_ABI
 
 namespace madlib {
 
diff --git a/src/ports/postgres/dbconnector/NativeRandomNumberGenerator_impl.hpp b/src/ports/postgres/dbconnector/NativeRandomNumberGenerator_impl.hpp
index c64c39d..126c2b8 100644
--- a/src/ports/postgres/dbconnector/NativeRandomNumberGenerator_impl.hpp
+++ b/src/ports/postgres/dbconnector/NativeRandomNumberGenerator_impl.hpp
@@ -41,7 +41,7 @@
  * @brief Return tight lower bound on the set of all values returned by
  *     <tt>operator()</tt>
  */
-inline
+inline CONST_EXPR
 NativeRandomNumberGenerator::result_type
 NativeRandomNumberGenerator::min() {
     return 0.0;
@@ -57,7 +57,7 @@
  * shall not change during the lifetime of the object."
  * http://www.boost.org/doc/libs/1_50_0/doc/html/boost_random/reference.html
  */
-inline
+inline CONST_EXPR
 NativeRandomNumberGenerator::result_type
 NativeRandomNumberGenerator::max() {
     return 1.0;
diff --git a/src/ports/postgres/dbconnector/NativeRandomNumberGenerator_proto.hpp b/src/ports/postgres/dbconnector/NativeRandomNumberGenerator_proto.hpp
index c1cd4b2..f7f5555 100644
--- a/src/ports/postgres/dbconnector/NativeRandomNumberGenerator_proto.hpp
+++ b/src/ports/postgres/dbconnector/NativeRandomNumberGenerator_proto.hpp
@@ -22,13 +22,20 @@
  */
 class NativeRandomNumberGenerator {
 public:
+
+#if _GLIBCXX_USE_CXX11_ABI
+    typedef long long result_type;
+#define CONST_EXPR constexpr
+#else
     typedef double result_type;
+#define CONST_EXPR
+#endif
 
     NativeRandomNumberGenerator();
     void seed(result_type inSeed);
     result_type operator()();
-    static result_type min();
-    static result_type max();
+    static CONST_EXPR result_type min();
+    static CONST_EXPR result_type max();
 };
 
 } // namespace postgres
diff --git a/src/ports/postgres/dbconnector/dbconnector.hpp b/src/ports/postgres/dbconnector/dbconnector.hpp
index 523fd1c..76eaf8a 100644
--- a/src/ports/postgres/dbconnector/dbconnector.hpp
+++ b/src/ports/postgres/dbconnector/dbconnector.hpp
@@ -85,9 +85,11 @@
 #include <boost/type_traits/remove_cv.hpp>
 #include <boost/math/special_functions/fpclassify.hpp>
 #include <boost/utility/enable_if.hpp>
+#if !_GLIBCXX_USE_CXX11_ABI
 #include <boost/tr1/array.hpp>
 #include <boost/tr1/functional.hpp>
 #include <boost/tr1/tuple.hpp>
+#endif // _GLIBCXX_USE_CXX11_ABI
 #include <algorithm>
 #include <complex>
 #include <limits>
@@ -99,6 +101,7 @@
 #include <utils/Reference.hpp>
 #include <utils/Math.hpp>
 
+#if !_GLIBCXX_USE_CXX11_ABI
 namespace std {
     // Import names from TR1.
 
@@ -111,6 +114,7 @@
     using tr1::tie;
     using tr1::tuple;
 }
+#endif // _GLIBCXX_USE_CXX11_ABI
 
 #if !defined(NDEBUG) && !defined(EIGEN_NO_DEBUG)
 #define eigen_assert(x) \