From 2f6387f239634ec2fb3d00ca65a8d044c11137fe Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Tue, 16 Jun 2020 14:18:05 -0700 Subject: [PATCH] Restore C++14 compatibility Summary: Fix the new CPU implementation of point_mesh functionality to be compatible with older C++. Reviewed By: nikhilaravi Differential Revision: D22066785 fbshipit-source-id: a245849342019a93ff68e186a10985458b007436 --- pytorch3d/csrc/point_mesh/point_mesh.cpp | 42 ++++++++++-------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/pytorch3d/csrc/point_mesh/point_mesh.cpp b/pytorch3d/csrc/point_mesh/point_mesh.cpp index 59e5cefb..3480a801 100644 --- a/pytorch3d/csrc/point_mesh/point_mesh.cpp +++ b/pytorch3d/csrc/point_mesh/point_mesh.cpp @@ -11,38 +11,32 @@ template vec3 ExtractPoint(const at::TensorAccessor& t) { - return vec3(t[0], t[1], t[2]); + return vec3(t[0], t[1], t[2]); } -template -struct ExtractHullHelper { - template - static std::array>, H> - get(const Accessor& t); +template +static std::array>, 1> +ExtractHullHelper(const Accessor& t, std::array /*tag*/) { + return {ExtractPoint(t)}; +} - template <> - static std::array>, 1> - get<1>(const Accessor& t) { - return {ExtractPoint(t)}; - } +template +static std::array>, 2> +ExtractHullHelper(const Accessor& t, std::array /*tag*/) { + return {ExtractPoint(t[0]), ExtractPoint(t[1])}; +} - template <> - static std::array>, 2> - get<2>(const Accessor& t) { - return {ExtractPoint(t[0]), ExtractPoint(t[1])}; - } - - template <> - static std::array>, 3> - get<3>(const Accessor& t) { - return {ExtractPoint(t[0]), ExtractPoint(t[1]), ExtractPoint(t[2])}; - } -}; +template +static std::array>, 3> +ExtractHullHelper(const Accessor& t, std::array /*tag*/) { + return {ExtractPoint(t[0]), ExtractPoint(t[1]), ExtractPoint(t[2])}; +} template std::array>, H> ExtractHull(const Accessor& t) { - return ExtractHullHelper::template get(t); + std::array tag; + return ExtractHullHelper(t, tag); } template