Removed CERES_USE_CXX11
Remove the special handling for tr1::shared_ptr.
Change-Id: Ic405dcfe881dd6560d236956f84bfb8911d0bcbb
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 845745d..c78dc41 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -443,7 +443,6 @@
# Set the Ceres option for C++11.
# TODO(alex): Remove when #defines are removed from source & config.h
list(APPEND CERES_COMPILE_OPTIONS CERES_STD_UNORDERED_MAP)
-list(APPEND CERES_COMPILE_OPTIONS CERES_USE_CXX11)
if (TBB)
find_package(TBB QUIET)
diff --git a/cmake/CeresCompileOptionsToComponents.cmake b/cmake/CeresCompileOptionsToComponents.cmake
index 2243ab3..872d9dc 100644
--- a/cmake/CeresCompileOptionsToComponents.cmake
+++ b/cmake/CeresCompileOptionsToComponents.cmake
@@ -81,8 +81,6 @@
add_to_output_if_not_found(CURRENT_CERES_COMPILE_OPTIONS ${CERES_COMPONENTS_VAR}
CERES_RESTRICT_SCHUR_SPECIALIZATION "SchurSpecializations")
add_to_output_if_found(CURRENT_CERES_COMPILE_OPTIONS ${CERES_COMPONENTS_VAR}
- CERES_USE_CXX11 "C++11")
- add_to_output_if_found(CURRENT_CERES_COMPILE_OPTIONS ${CERES_COMPONENTS_VAR}
CERES_USE_OPENMP "OpenMP;Multithreading")
add_to_output_if_found(CURRENT_CERES_COMPILE_OPTIONS ${CERES_COMPONENTS_VAR}
CERES_USE_TBB "TBB;Multithreading")
diff --git a/cmake/config.h.in b/cmake/config.h.in
index 032db42..76b853c 100644
--- a/cmake/config.h.in
+++ b/cmake/config.h.in
@@ -60,9 +60,6 @@
// routines.
@CERES_NO_CUSTOM_BLAS@
-// If defined, Ceres was compiled with C++11.
-@CERES_USE_CXX11@
-
// If defined, Ceres was compiled without multithreading support.
@CERES_NO_THREADS@
// If defined Ceres was compiled with OpenMP multithreading support.
diff --git a/include/ceres/internal/port.h b/include/ceres/internal/port.h
index e4acf35..f0f706c 100644
--- a/include/ceres/internal/port.h
+++ b/include/ceres/internal/port.h
@@ -64,12 +64,6 @@
namespace ceres {
-#if defined(CERES_TR1_SHARED_PTR)
-using std::tr1::shared_ptr;
-#else
-using std::shared_ptr;
-#endif
-
// We allocate some Eigen objects on the stack and other places they
// might not be aligned to X(=16 [SSE], 32 [AVX] etc)-byte boundaries. If we
// have C++11, we can specify their alignment (which is desirable, as it means
@@ -79,7 +73,6 @@
// on some platforms, in which case even if using C++11, on these platforms
// we should not attempt to align to X-byte boundaries. If using < C++11,
// we cannot specify the alignment.
-#ifdef CERES_USE_CXX11
namespace port_constants {
static constexpr size_t kMaxAlignBytes =
// Work around a GCC 4.8 bug
@@ -91,7 +84,6 @@
alignof(std::max_align_t);
#endif
} // namespace port_constants
-#endif
} // namespace ceres
diff --git a/include/ceres/jet.h b/include/ceres/jet.h
index 7d28e37..5b56d86 100644
--- a/include/ceres/jet.h
+++ b/include/ceres/jet.h
@@ -258,7 +258,7 @@
// supported is < 16, in which case we do not specify an alignment, as this
// implies the host is not a modern x86 machine. If using < C++11, we cannot
// specify alignment.
-#if !defined(CERES_USE_CXX11) || defined(EIGEN_DONT_VECTORIZE)
+#if defined(EIGEN_DONT_VECTORIZE)
// Without >= C++11, we cannot specify the alignment so fall back to safe,
// unvectorised version.
Eigen::Matrix<T, N, 1, Eigen::DontAlign> v;
@@ -445,16 +445,12 @@
inline double ceil (double x) { return std::ceil(x); }
inline double pow (double x, double y) { return std::pow(x, y); }
inline double atan2(double y, double x) { return std::atan2(y, x); }
-
-#ifdef CERES_USE_CXX11
-// Some new additions to C++11:
inline double cbrt (double x) { return std::cbrt(x); }
inline double exp2 (double x) { return std::exp2(x); }
inline double log2 (double x) { return std::log2(x); }
inline double hypot(double x, double y) { return std::hypot(x, y); }
inline double fmax(double x, double y) { return std::fmax(x, y); }
inline double fmin(double x, double y) { return std::fmin(x, y); }
-#endif
// In general, f(a + h) ~= f(a) + f'(a) h, via the chain rule.
@@ -565,7 +561,6 @@
return Jet<T, N>(ceil(f.a));
}
-#ifdef CERES_USE_CXX11
// Some new additions to C++11:
// cbrt(a + h) ~= cbrt(a) + h / (3 a ^ (2/3))
@@ -614,7 +609,6 @@
const Jet<T, N>& fmin(const Jet<T, N>& x, const Jet<T, N>& y) {
return y < x ? y : x;
}
-#endif // CERES_USE_CXX11
// Bessel functions of the first kind with integer order equal to 0, 1, n.
//
diff --git a/include/ceres/solver.h b/include/ceres/solver.h
index 2926f8e..09157cc 100644
--- a/include/ceres/solver.h
+++ b/include/ceres/solver.h
@@ -32,6 +32,7 @@
#define CERES_PUBLIC_SOLVER_H_
#include <cmath>
+#include <memory>
#include <string>
#include <vector>
#include "ceres/crs_matrix.h"
@@ -500,7 +501,7 @@
// the parameter blocks into two groups, one for the points and one
// for the cameras, where the group containing the points has an id
// smaller than the group containing cameras.
- shared_ptr<ParameterBlockOrdering> linear_solver_ordering;
+ std::shared_ptr<ParameterBlockOrdering> linear_solver_ordering;
// Use an explicitly computed Schur complement matrix with
// ITERATIVE_SCHUR.
@@ -631,7 +632,7 @@
// the lower numbered groups are optimized before the higher
// number groups. Each group must be an independent set. Not
// all parameter blocks need to be present in the ordering.
- shared_ptr<ParameterBlockOrdering> inner_iteration_ordering;
+ std::shared_ptr<ParameterBlockOrdering> inner_iteration_ordering;
// Generally speaking, inner iterations make significant progress
// in the early stages of the solve and then their contribution
diff --git a/internal/ceres/jet_test.cc b/internal/ceres/jet_test.cc
index f3e42fd..188d9f5 100644
--- a/internal/ceres/jet_test.cc
+++ b/internal/ceres/jet_test.cc
@@ -567,7 +567,6 @@
EXPECT_EQ(expected, b);
}
- #ifdef CERES_USE_CXX11
{ // Check that cbrt(x * x * x) == x.
J z = x * x * x;
J w = cbrt(z);
@@ -696,7 +695,6 @@
ExpectJetsClose(y, z);
}
- #endif
}
TEST(Jet, JetsInEigenMatrices) {
diff --git a/internal/ceres/minimizer.h b/internal/ceres/minimizer.h
index b593728..afdd60d 100644
--- a/internal/ceres/minimizer.h
+++ b/internal/ceres/minimizer.h
@@ -31,6 +31,7 @@
#ifndef CERES_INTERNAL_MINIMIZER_H_
#define CERES_INTERNAL_MINIMIZER_H_
+#include <memory>
#include <string>
#include <vector>
#include "ceres/internal/port.h"
@@ -167,19 +168,19 @@
// Object responsible for evaluating the cost, residuals and
// Jacobian matrix.
- shared_ptr<Evaluator> evaluator;
+ std::shared_ptr<Evaluator> evaluator;
// Object responsible for actually computing the trust region
// step, and sizing the trust region radius.
- shared_ptr<TrustRegionStrategy> trust_region_strategy;
+ std::shared_ptr<TrustRegionStrategy> trust_region_strategy;
// Object holding the Jacobian matrix. It is assumed that the
// sparsity structure of the matrix has already been initialized
// and will remain constant for the life time of the
// optimization.
- shared_ptr<SparseMatrix> jacobian;
+ std::shared_ptr<SparseMatrix> jacobian;
- shared_ptr<CoordinateDescentMinimizer> inner_iteration_minimizer;
+ std::shared_ptr<CoordinateDescentMinimizer> inner_iteration_minimizer;
};
static Minimizer* Create(MinimizerType minimizer_type);
diff --git a/internal/ceres/parallel_for_cxx.cc b/internal/ceres/parallel_for_cxx.cc
index bfc8973..3da5a87 100644
--- a/internal/ceres/parallel_for_cxx.cc
+++ b/internal/ceres/parallel_for_cxx.cc
@@ -182,11 +182,11 @@
return;
}
- // We use a shared_ptr because the main thread can finish all the work before
- // the tasks have been popped off the queue. So the shared state needs to
- // exist for the duration of all the tasks.
+ // We use a std::shared_ptr because the main thread can finish all
+ // the work before the tasks have been popped off the queue. So the
+ // shared state needs to exist for the duration of all the tasks.
const int num_work_items = std::min((end - start), num_threads);
- shared_ptr<SharedState> shared_state(
+ std::shared_ptr<SharedState> shared_state(
new SharedState(start, end, num_work_items));
// A function which tries to perform a chunk of work. This returns false if
diff --git a/internal/ceres/preprocessor.h b/internal/ceres/preprocessor.h
index ff53d6f..ce2eec5 100644
--- a/internal/ceres/preprocessor.h
+++ b/internal/ceres/preprocessor.h
@@ -31,6 +31,7 @@
#ifndef CERES_INTERNAL_PREPROCESSOR_H_
#define CERES_INTERNAL_PREPROCESSOR_H_
+#include <memory>
#include <string>
#include <vector>
@@ -97,8 +98,8 @@
scoped_ptr<IterationCallback> logging_callback;
scoped_ptr<IterationCallback> state_updating_callback;
- shared_ptr<Evaluator> evaluator;
- shared_ptr<CoordinateDescentMinimizer> inner_iteration_minimizer;
+ std::shared_ptr<Evaluator> evaluator;
+ std::shared_ptr<CoordinateDescentMinimizer> inner_iteration_minimizer;
std::vector<double*> removed_parameter_blocks;
Vector reduced_parameters;