diff --git a/include/pymol/algorithm.h b/include/pymol/algorithm.h index 91aed83ac..624a8fd83 100644 --- a/include/pymol/algorithm.h +++ b/include/pymol/algorithm.h @@ -27,30 +27,6 @@ template void erase_if(C& c, Pred pred) #endif } -/** - * @brief C++17's version of std::clamp - */ -template -const T& clamp(const T& value, const T& low, const T& high){ - assert(low <= high); - return std::max(low, std::min(value, high)); -} - -/** - * @brief C++14's std::equal - */ - -template -bool equal(InIter1 first1, InIter1 last1, InIter2 first2) -{ - for (; first1 != last1; ++first1, ++first2) { - if (*first1 != *first2) { - return false; - } - } - return true; -} - /** * @brief Checks whether two floating point values are nearly equal * @param first floating point number @@ -60,7 +36,7 @@ bool equal(InIter1 first1, InIter1 last1, InIter2 first2) * @tparam U second floating point type */ -template > +template > bool almost_equal(T a, U b, CommonT epsilon = 1e-6) { return std::abs(a - b) <= epsilon; @@ -136,7 +112,7 @@ bool equal(const RangeT1& first, const RangeT2& second) if (range1Size != range2Size) { return false; } - return pymol::equal(std::begin(first), std::end(first), std::begin(second)); + return std::equal(std::begin(first), std::end(first), std::begin(second)); } /** @@ -164,7 +140,7 @@ bool equal(const RangeT1& first, const RangeT2& second, Pred p) } } return true; - //return pymol::equal(std::begin(first), std::end(first), std::begin(second)); + //return std::equal(std::begin(first), std::end(first), std::begin(second)); } /** diff --git a/include/pymol/functional.h b/include/pymol/functional.h deleted file mode 100644 index c27bab52f..000000000 --- a/include/pymol/functional.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -namespace pymol -{ - -/** - * C++17's invoke - * @param f Function to be invoked - * @param args arguments to supply to function - * Note: Does not return reference until C++14 - */ - -template -/*decltype(auto)*/ auto invoke(Func&& f, FuncArgs&&... args) - -> decltype(std::forward(f)(std::forward(args)...)) -{ - return std::forward(f)(std::forward(args)...); -} - -} // namespace pymol diff --git a/include/pymol/memory.h b/include/pymol/memory.h index d79d5a96c..23142ed00 100644 --- a/include/pymol/memory.h +++ b/include/pymol/memory.h @@ -6,48 +6,6 @@ namespace pymol { - -#if __cplusplus >= 201402L -using std::make_unique; -#else -/** - * @brief C++14's std::make_unique - * @param args arguments for constructor of Type T - * @return A std::unique_ptr for type T - */ - -template -std::unique_ptr make_unique(Args &&... args) { - return std::unique_ptr(new T(std::forward(args)...)); -} - -template ::value>> -std::unique_ptr make_unique(std::size_t size){ - return std::unique_ptr(new pymol::remove_extent_t[size]()); -} -#endif - -#if __cplusplus >= 201703L -using std::destroy_at; -using std::destroy; -#else -/* - * @brief C++17's std::destroy_at - */ -template void destroy_at(T* p) { p->~T(); } - -/* - * @brief C++17's std::destroy - */ - -template void destroy(T* iter, T* end) -{ - for(; iter != end; ++iter) { - destroy_at(std::addressof(*iter)); - } -} -#endif - /** * A copyable unique pointer. Will make a copy of the managed object with "new". */ diff --git a/include/pymol/tuple.h b/include/pymol/tuple.h deleted file mode 100644 index 556101711..000000000 --- a/include/pymol/tuple.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include "pymol/functional.h" -#include "pymol/type_traits.h" -#include "pymol/utility.h" - -namespace pymol -{ - -/* - * C++17's std::apply - * requires pymol::(or std::)index_sequence - * Takes a function and a tuple of lvalue/rvalue references to arguments - * and applys them to a function - */ - -namespace apply_detail -{ -template -/*decltype(auto)*/ auto apply_impl(Func&& f, TupleArgs&& t, - index_sequence) -> decltype(pymol::invoke(std::forward(f), - std::get(std::forward(t))...)) -{ - return pymol::invoke( - std::forward(f), std::get(std::forward(t))...); -} -} // namespace apply_detail - -template -/*decltype(auto)*/ auto apply(F&& f, TupleArgs&& t) -> decltype( - apply_detail::apply_impl(std::forward(f), std::forward(t), - make_index_sequence< - std::tuple_size>::value>{})) -{ - return apply_detail::apply_impl(std::forward(f), - std::forward(t), - make_index_sequence< - std::tuple_size>::value>{}); -} - -} // namespace pymol diff --git a/include/pymol/type_traits.h b/include/pymol/type_traits.h index 8135ebcad..8570dcd5a 100644 --- a/include/pymol/type_traits.h +++ b/include/pymol/type_traits.h @@ -6,43 +6,16 @@ namespace pymol { -template -using decay_t = typename std::decay::type; - -template -using enable_if_t = typename std::enable_if::type; - -template -using remove_reference_t = typename std::remove_reference::type; - -template -using remove_cv_t = typename std::remove_cv::type; - -template -using remove_cvref_t = remove_cv_t>; - -template -using remove_extent_t = typename std::remove_extent::type; - -template -using common_type_t = typename std::common_type::type; - -template -using result_of_t = typename std::result_of::type; - // Non-STL -template -using forward_check_t = pymol::enable_if_t, U>::value>; - //! Casts a pointer of type T to a pointer of type T[N] -template remove_reference_t reshape(T* flat) +template std::remove_reference_t reshape(T* flat) { return reinterpret_cast(flat); } //! Casts a pointer of type T[N] to a pointer of type T -template remove_extent_t* flatten(T* shaped) +template std::remove_extent_t* flatten(T* shaped) { - return reinterpret_cast*>(shaped); + return reinterpret_cast*>(shaped); } } diff --git a/layer0/Bezier.cpp b/layer0/Bezier.cpp index 584e5f38d..a1e2f0805 100644 --- a/layer0/Bezier.cpp +++ b/layer0/Bezier.cpp @@ -88,7 +88,7 @@ void BezierSpline::addBezierPoint() std::pair BezierSpline::getIndexAndLocalT(float globalT) const { - auto t = clamp(globalT, 0.0f, 1.0f); + auto t = std::clamp(globalT, 0.0f, 1.0f); if (t == 1.0f) { assert(bezierPoints.size() >= 2); return std::make_pair(static_cast(bezierPoints.size() - 2), t); @@ -108,7 +108,7 @@ glm::vec3 BezierSpline::GetBezierPoint( glm::vec3 BezierSpline::GetBezierPoint(const glm::vec3& p0, const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& p3, float t) { - t = clamp(t, 0.0f, 1.0f); + t = std::clamp(t, 0.0f, 1.0f); float oneMinusT = 1.0f - t; return oneMinusT * oneMinusT * oneMinusT * p0 + 3.0f * oneMinusT * oneMinusT * t * p1 + 3.0f * oneMinusT * t * t * p2 + @@ -118,7 +118,7 @@ glm::vec3 BezierSpline::GetBezierPoint(const glm::vec3& p0, const glm::vec3& p1, glm::vec3 BezierSpline::GetBezierFirstDerivative(const glm::vec3& p0, const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& p3, float t) { - t = clamp(t, 0.0f, 1.0f); + t = std::clamp(t, 0.0f, 1.0f); float oneMinusT = 1.0f - t; return 3.0f * oneMinusT * oneMinusT * (p1 - p0) + 6.0f * oneMinusT * t * (p2 - p1) + 3.0f * t * t * (p3 - p2); diff --git a/layer0/Event.h b/layer0/Event.h index 7c0e86911..3daa49f0f 100644 --- a/layer0/Event.h +++ b/layer0/Event.h @@ -2,7 +2,6 @@ #include #include -#include "pymol/functional.h" namespace pymol { @@ -19,7 +18,7 @@ template class Event return; } for (const auto& callback : m_callbacks) { - pymol::invoke(callback, params...); + std::invoke(callback, params...); } } diff --git a/layer0/Map.cpp b/layer0/Map.cpp index c74e714f0..e8aac4058 100644 --- a/layer0/Map.cpp +++ b/layer0/Map.cpp @@ -613,9 +613,9 @@ void MapLocus(const MapType * I, const float *v, int *a, int *b, int *c) bt = (int) ((v[1] - I->Min[1]) * invDiv) + MapBorder; ct = (int) ((v[2] - I->Min[2]) * invDiv) + MapBorder; - *a = pymol::clamp(at, I->iMin[0], I->iMax[0]); - *b = pymol::clamp(bt, I->iMin[1], I->iMax[1]); - *c = pymol::clamp(ct, I->iMin[2], I->iMax[2]); + *a = std::clamp(at, I->iMin[0], I->iMax[0]); + *b = std::clamp(bt, I->iMin[1], I->iMax[1]); + *c = std::clamp(ct, I->iMin[2], I->iMax[2]); } /** diff --git a/layer0/MyPNG.cpp b/layer0/MyPNG.cpp index 69331c77e..1707f3e22 100644 --- a/layer0/MyPNG.cpp +++ b/layer0/MyPNG.cpp @@ -497,7 +497,7 @@ std::unique_ptr MyPNGRead(const char *file_name) png_read_end(png_ptr, info_ptr); } - img = pymol::make_unique(width, height); + img = std::make_unique(width, height); if(ok) { auto p = img->bits(); for(row = 0; row < (signed) height; row++) { diff --git a/layer0/PostProcess.cpp b/layer0/PostProcess.cpp index d4a5c4db9..84a226d19 100644 --- a/layer0/PostProcess.cpp +++ b/layer0/PostProcess.cpp @@ -58,11 +58,11 @@ const renderTarget_t::shape_type PostProcess::size(std::size_t idx) const OIT_PostProcess::OIT_PostProcess(int width, int height, renderBuffer_t* rbo) { if (TM3_IS_ONEBUF) { - auto rt0 = pymol::make_unique(width, height); + auto rt0 = std::make_unique(width, height); rt0->layout({{4, rt_layout_t::FLOAT}}, rbo); m_renderTargets.push_back(std::move(rt0)); - auto rt1 = pymol::make_unique(width, height); + auto rt1 = std::make_unique(width, height); rt1->layout({{1, rt_layout_t::FLOAT}}, rt0->rbo()); m_renderTargets.push_back(std::move(rt1)); } else { @@ -74,7 +74,7 @@ OIT_PostProcess::OIT_PostProcess(int width, int height, renderBuffer_t* rbo) layouts.emplace_back(2, rt_layout_t::FLOAT); } - auto rt0 = pymol::make_unique(width, height); + auto rt0 = std::make_unique(width, height); rt0->layout(std::move(layouts), rbo); m_renderTargets.push_back(std::move(rt0)); } diff --git a/layer0/ShaderMgr.cpp b/layer0/ShaderMgr.cpp index 9fb73f3b3..726599872 100644 --- a/layer0/ShaderMgr.cpp +++ b/layer0/ShaderMgr.cpp @@ -1742,7 +1742,7 @@ void CShaderMgr::bindOffscreenOIT(int width, int height, int drawbuf) { renderTarget_t::shape_type req_size(width, height); if(!oit_pp || oit_pp->size() != req_size) { - oit_pp = pymol::make_unique( + oit_pp = std::make_unique( width, height, getGPUBuffer(offscreen_rt)->_rbo); } else { if (!TM3_IS_ONEBUF) { diff --git a/layer1/CGO.cpp b/layer1/CGO.cpp index 03e051d52..ff9dbf543 100644 --- a/layer1/CGO.cpp +++ b/layer1/CGO.cpp @@ -4103,7 +4103,7 @@ CGO *CGOOptimizeSpheresToVBONonIndexed(const CGO * I, int est, bool addshaders, CGO* CGOOptimizeBezier(const CGO* I) { - auto cgo = pymol::make_unique(I->G); + auto cgo = std::make_unique(I->G); int num_splines = CGOCountNumberOfOperationsOfType(I, CGO_BEZIER); auto vbo = I->G->ShaderMgr->newGPUBuffer(); std::vector vertData; diff --git a/layer1/CGOGL.cpp b/layer1/CGOGL.cpp index ed74b12fb..369bbced4 100644 --- a/layer1/CGOGL.cpp +++ b/layer1/CGOGL.cpp @@ -2537,7 +2537,7 @@ void CGORenderGLAlpha(CGO* I, RenderInfo* info, bool calcDepth) float* const pc = it.data(); assert(base < pc && pc < I->op + I->c); auto i = - pymol::clamp((pc[4] - I->z_min) * range_factor, 0, i_size); + std::clamp((pc[4] - I->z_min) * range_factor, 0, i_size); CGO_put_int(pc, start[i]); start[i] = (pc - base); /* NOTE: will always be > 0 since we have CGO_read_int'd */ diff --git a/layer1/Extrude.cpp b/layer1/Extrude.cpp index 857fcfe7d..a00201aee 100644 --- a/layer1/Extrude.cpp +++ b/layer1/Extrude.cpp @@ -627,7 +627,7 @@ void ExtrudeShiftToAxis(CExtrude* I, float radius, int sampling) float* avg = smoothed.data() + (a - 1) * 3; for (int j = -w2; j <= w2; ++j) { - int const k = pymol::clamp(a + j, 0, I->N - 1); + int const k = std::clamp(a + j, 0, I->N - 1); add3f(I->p + k * 3, avg, avg); } diff --git a/layer1/Ortho.cpp b/layer1/Ortho.cpp index fbdd49735..4adbead98 100644 --- a/layer1/Ortho.cpp +++ b/layer1/Ortho.cpp @@ -1319,7 +1319,7 @@ void OrthoBackgroundTextureNeedsUpdate(PyMOLGlobals * G){ static std::unique_ptr makeBgGridImage(PyMOLGlobals* G) { auto const& grid = G->Scene->grid; - auto tmpImg = pymol::make_unique( // + auto tmpImg = std::make_unique( // grid.n_col > 1 ? grid.n_col : 1, // grid.n_row > 1 ? grid.n_row : 1); @@ -1343,7 +1343,7 @@ static std::unique_ptr makeBgGradientImage(PyMOLGlobals* G) { constexpr unsigned height = BACKGROUND_TEXTURE_SIZE; - auto tmpImg = pymol::make_unique(1, height); + auto tmpImg = std::make_unique(1, height); float top[3], bottom[3], mixed[4]{0, 0, 0, 1}; copy3f(ColorGet(G, SettingGet_color(G, cSetting_bg_rgb_top)), top); diff --git a/layer1/SceneRay.cpp b/layer1/SceneRay.cpp index 7daedcea5..857067caa 100644 --- a/layer1/SceneRay.cpp +++ b/layer1/SceneRay.cpp @@ -336,7 +336,7 @@ bool SceneRay(PyMOLGlobals * G, switch (mode) { case 0: /* mode 0 is built-in */ { - auto image = pymol::make_unique(ray_width, ray_height); + auto image = std::make_unique(ray_width, ray_height); std::uint32_t background; RayRender(ray, image->pixels(), timing, angle, antialias, &background); @@ -346,7 +346,7 @@ bool SceneRay(PyMOLGlobals * G, I->Image = std::move(image); } else { if(!I->Image) { /* alloc on first pass */ - I->Image = pymol::make_unique(tot_width, tot_height); + I->Image = std::make_unique(tot_width, tot_height); if(I->Image) { unsigned int tot_size = tot_width * tot_height; { /* fill with background color */ diff --git a/layer1/ScrollBar.cpp b/layer1/ScrollBar.cpp index e8ce0100a..b73555f57 100644 --- a/layer1/ScrollBar.cpp +++ b/layer1/ScrollBar.cpp @@ -48,7 +48,7 @@ void ScrollBar::update() m_ValueMax = static_cast(m_ListSize - m_DisplaySize); if(m_ValueMax < 1) m_ValueMax = 1; - m_Value = pymol::clamp(m_Value, 0.0f, m_ValueMax); + m_Value = std::clamp(m_Value, 0.0f, m_ValueMax); } void ScrollBar::fill(CGO* orthoCGO) diff --git a/layer1/ScrollBar.h b/layer1/ScrollBar.h index 51a6be0e3..36d1a9ee6 100644 --- a/layer1/ScrollBar.h +++ b/layer1/ScrollBar.h @@ -61,7 +61,7 @@ class ScrollBar : public Block { bool isMaxed() const; void fill(CGO *orthoCGO); void setValueNoCheck(float _value) { m_Value = _value; } - void setValue(float _value){ m_Value = pymol::clamp(_value, 0.0f, m_ValueMax); } + void setValue(float _value){ m_Value = std::clamp(_value, 0.0f, m_ValueMax); } void drawNoFill(CGO *orthoCGO) { drawImpl(false, orthoCGO); } int grabbed() { return OrthoGrabbedBy(m_G, this); } float getValue() const { return m_Value; } diff --git a/layer2/CoordSet.cpp b/layer2/CoordSet.cpp index cd7066f51..cfa3a351c 100644 --- a/layer2/CoordSet.cpp +++ b/layer2/CoordSet.cpp @@ -1288,7 +1288,7 @@ void CoordSet::update(int state) auto use_shader = SettingGet(G, cSetting_use_shaders); if (use_shader) { auto color = ColorGet(G, Obj->Color); - auto preCGO = pymol::make_unique(G); + auto preCGO = std::make_unique(G); CGOColorv(preCGO.get(), color); CGOAppendNoStop(preCGO.get(), UnitCellCGO.get()); std::unique_ptr optimized(CGOOptimizeToVBONotIndexed(preCGO.get(), 0)); @@ -1507,7 +1507,7 @@ CoordSet::CoordSet(const CoordSet& cs) this->NTmpLinkBond = cs.NTmpLinkBond; /* deep copy & return ptr to new symmetry */ if(cs.Symmetry) { - this->Symmetry = pymol::make_unique(*cs.Symmetry); + this->Symmetry = std::make_unique(*cs.Symmetry); } std::copy(std::begin(cs.Name), std::end(cs.Name), std::begin(this->Name)); this->PeriodicBoxType = cs.PeriodicBoxType; diff --git a/layer2/ObjectCurve.cpp b/layer2/ObjectCurve.cpp index 0d1ee7324..4f73bfbbf 100644 --- a/layer2/ObjectCurve.cpp +++ b/layer2/ObjectCurve.cpp @@ -130,7 +130,7 @@ void ObjectCurveState::updateRawCGO() static CGO* FilterCGO(PyMOLGlobals* G, const CGO* rawCGO) { - auto optCGO = pymol::make_unique(G); + auto optCGO = std::make_unique(G); CGO* allCylinders = nullptr; CGO* allBeziers = nullptr; CGO* allSpheres = nullptr; diff --git a/layer2/ObjectMap.cpp b/layer2/ObjectMap.cpp index bfe2a25f5..8c192e8a1 100644 --- a/layer2/ObjectMap.cpp +++ b/layer2/ObjectMap.cpp @@ -4886,7 +4886,7 @@ static pymol::Result> ObjectMapDXStrToMap( char cc[MAXLINELEN]; - auto ms = pymol::make_unique(G); + auto ms = std::make_unique(G); ms->Origin = std::vector(3); ms->Grid = std::vector(3); diff --git a/layer2/ObjectMolecule.cpp b/layer2/ObjectMolecule.cpp index 3c435d649..1479e5ba1 100644 --- a/layer2/ObjectMolecule.cpp +++ b/layer2/ObjectMolecule.cpp @@ -1103,7 +1103,7 @@ ObjectMolecule *ObjectMoleculeLoadTRJFile(PyMOLGlobals * G, ObjectMolecule * I, if(sscanf(cc, "%f", &angle[2]) != 1) angles = false; if(periodic) { - cs->Symmetry = pymol::make_unique(G); + cs->Symmetry = std::make_unique(G); cs->Symmetry->Crystal.setDims(box); if(angles) { cs->Symmetry->Crystal.setAngles(angle); @@ -2171,7 +2171,7 @@ static CoordSet *ObjectMoleculeTOPStr2CoordSet(PyMOLGlobals * G, const char *buf angle[2] = 60.0; } - cset->Symmetry = pymol::make_unique(G); + cset->Symmetry = std::make_unique(G); cset->Symmetry->Crystal.setDims(BOX1, BOX2, BOX3); cset->Symmetry->Crystal.setAngles(angle); } @@ -3259,7 +3259,7 @@ pymol::Result<> ObjectMoleculeFuse(ObjectMolecule* I, int const index0, } /* copy atoms and atom info into a 1:1 direct mapping */ - auto cs = pymol::make_unique(G); + auto cs = std::make_unique(G); cs->setNIndex(scs->NIndex); cs->enumIndices(); diff --git a/layer2/ObjectMolecule2.cpp b/layer2/ObjectMolecule2.cpp index 8c879e3a5..857876a92 100644 --- a/layer2/ObjectMolecule2.cpp +++ b/layer2/ObjectMolecule2.cpp @@ -3743,7 +3743,7 @@ bool ObjectMoleculeConnect(ObjectMolecule* I, int& nBond, pymol::vla& // For monitoring excessive numbers of bonds int violations = 0; auto const max_violations = cs->NIndex >> 3; // 12% - auto const cnt = pymol::make_unique(size_t(cs->NIndex)); + auto const cnt = std::make_unique(size_t(cs->NIndex)); p_return_val_if_fail(cnt, false); // memory error /* initialize each atom's (max) expected valence */ diff --git a/layer2/ObjectSurface.cpp b/layer2/ObjectSurface.cpp index fd6ec1bc2..3a8e90762 100644 --- a/layer2/ObjectSurface.cpp +++ b/layer2/ObjectSurface.cpp @@ -873,7 +873,7 @@ static void ObjectSurfaceRenderCell(PyMOLGlobals *G, ObjectSurface * I, const float *color = ColorGet(G, I->Color); if (use_shader != ms->UnitCellCGO->has_draw_buffers){ if (use_shader){ - auto preCGO = pymol::make_unique(G); + auto preCGO = std::make_unique(G); CGOColorv(preCGO.get(), color); CGOAppendNoStop(preCGO.get(), ms->UnitCellCGO.get()); std::unique_ptr optimized(CGOOptimizeToVBONotIndexed(preCGO.get(), 0)); diff --git a/layer2/RepDistLabel.cpp b/layer2/RepDistLabel.cpp index e11bf4e34..9b5ee943f 100644 --- a/layer2/RepDistLabel.cpp +++ b/layer2/RepDistLabel.cpp @@ -247,7 +247,7 @@ Rep *RepDistLabelNew(DistSet * ds, int state) return nullptr; } - default_digits = pymol::clamp(default_digits, 0, 10); + default_digits = std::clamp(default_digits, 0, 10); auto I = new RepDistLabel(ds->Obj, state); diff --git a/layer2/RepDot.cpp b/layer2/RepDot.cpp index 60c7021a2..38a4d1e23 100644 --- a/layer2/RepDot.cpp +++ b/layer2/RepDot.cpp @@ -298,7 +298,7 @@ Rep *RepDotDoNew(CoordSet * cs, cRepDot_t mode, int state) // get current dot sampling // Note: significantly affects the accuracy of our area comp. auto ds = SettingGet(G, cs->Setting.get(), obj->Setting.get(), cSetting_dot_density); - SphereRec const* sp = G->Sphere->Sphere[pymol::clamp(ds, 0, 4)]; + SphereRec const* sp = G->Sphere->Sphere[std::clamp(ds, 0, 4)]; int lastColor = cColorDefault; int colorCnt = 0; diff --git a/layer2/Sculpt.cpp b/layer2/Sculpt.cpp index e4036cc01..4ee4b2d79 100644 --- a/layer2/Sculpt.cpp +++ b/layer2/Sculpt.cpp @@ -235,7 +235,7 @@ static float ShakerDoDistMinim(float target, float *v0, float *v1, float *d0to1, CSculpt::CSculpt (PyMOLGlobals * G) { this->G = G; - this->Shaker = pymol::make_unique(G); + this->Shaker = std::make_unique(G); this->NBList = pymol::vla(150000); this->NBHash = std::vector(NB_HASH_SIZE); this->EXList = pymol::vla(100000); diff --git a/layer3/Executive.cpp b/layer3/Executive.cpp index 3edc886bd..a209b4098 100644 --- a/layer3/Executive.cpp +++ b/layer3/Executive.cpp @@ -5560,7 +5560,7 @@ int ExecutiveSetSession(PyMOLGlobals * G, PyObject * session, if (partial_restore) { G->SettingUnique->old2new = - pymol::make_unique>(); + std::make_unique>(); } if(ok) { @@ -16834,7 +16834,7 @@ pymol::Result<> ExecutiveCurveNew(PyMOLGlobals* G, if (oldObj) { return pymol::make_error("Curve of this name already exists."); } - auto obj = pymol::make_unique(G); + auto obj = std::make_unique(G); obj->setName(curveName); ExecutiveManageObject(G, obj.release(), false, true); return {}; @@ -16893,7 +16893,7 @@ static pymol::Result<> ExecutiveMoveCameraOnCurve( pymol::Result<> ExecutiveMoveOnCurve(PyMOLGlobals* G, pymol::zstring_view mobileObjectName, pymol::zstring_view curveObjectName, float t) { - t = pymol::clamp(t, 0.0f, 1.0f); + t = std::clamp(t, 0.0f, 1.0f); auto curveObj = ExecutiveFindObject(G, curveObjectName); if (!curveObj) { return pymol::make_error("Curve object not found."); diff --git a/layer3/Selector.cpp b/layer3/Selector.cpp index 6dff06b51..432ed8bb6 100644 --- a/layer3/Selector.cpp +++ b/layer3/Selector.cpp @@ -1357,7 +1357,7 @@ MapType *SelectorGetSpacialMapFromSeleCoord(PyMOLGlobals * G, int sele, int stat if(sele < 0) return NULL; else { - auto ptr = pymol::make_unique(G, G->SelectorMgr); + auto ptr = std::make_unique(G, G->SelectorMgr); CSelector mapSele(G, G->SelectorMgr); auto I = &mapSele; SelectorUpdateTableImpl(G, I, state, -1); diff --git a/layerCTest/Test.h b/layerCTest/Test.h index 92c3b1c88..63016d44b 100644 --- a/layerCTest/Test.h +++ b/layerCTest/Test.h @@ -58,7 +58,7 @@ static bool isArrayZero(const T *arr, const std::size_t len) { // Checks whether arrays are equal template static bool isArrayEqual(const T *arr1, const T *arr2, const std::size_t len) { - return pymol::equal(arr1, arr1 + len, arr2); + return std::equal(arr1, arr1 + len, arr2); } // Checks whether type has all special member functions diff --git a/layerCTest/Test_Algorithm.cpp b/layerCTest/Test_Algorithm.cpp index 3df425e7e..071184290 100644 --- a/layerCTest/Test_Algorithm.cpp +++ b/layerCTest/Test_Algorithm.cpp @@ -4,31 +4,6 @@ #include "pymol/algorithm.h" -TEST_CASE("Clamp", "[Algorithm]") -{ - REQUIRE(pymol::clamp(-1, 0, 10) == 0); - REQUIRE(pymol::clamp(3, 0, 10) == 3); - REQUIRE(pymol::clamp(13, 0, 10) == 10); -} - -TEST_CASE("Equal", "[Algorithm]") -{ - std::vector a{1, 2, 3, 4}; - std::vector b{1, 2, 3, 4, 5}; - REQUIRE(pymol::equal(a.begin(), a.end(), b.begin())); - b[3] = 42; - REQUIRE(!pymol::equal(a.begin(), a.end(), b.begin())); -} - -TEST_CASE("Almost Equal", "[Algorithm]") -{ - std::vector a{1, 2, 3, 4}; - std::vector b{1, 2, 3, 4, 5}; - REQUIRE(pymol::equal(a.begin(), a.end(), b.begin())); - b[3] = 42; - REQUIRE(!pymol::equal(a.begin(), a.end(), b.begin())); -} - TEST_CASE("Range Equal", "[Algorithm]") { std::array a{1, 2, 3, 4}; diff --git a/layerCTest/Test_Functional_Utility.cpp b/layerCTest/Test_Functional_Utility.cpp deleted file mode 100644 index cf0f18d31..000000000 --- a/layerCTest/Test_Functional_Utility.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include - -#include "pymol/tuple.h" -#include "pymol/functional.h" -#include "Test.h" - -TEST_CASE("Integer Sequence", "[FuncUtil]") -{ - pymol::integer_sequence intSeq; - static_assert(intSeq.size() == 4, "Incorrect integer sequence size"); - REQUIRE(intSeq.size() == 4); -} - -TEST_CASE("Make Integer Sequence", "[FuncUtil]") -{ - auto intSeq = pymol::make_integer_sequence(); - static_assert(intSeq.size() == 10, "Incorrect integer sequence size"); - REQUIRE(intSeq.size() == 10); -} - -TEST_CASE("Index Sequence", "[FuncUtil]") -{ - pymol::index_sequence<0, 1, 2, 3, 4, 5> idxSeq; - static_assert(idxSeq.size() == 6, "Incorrect integer sequence size"); - REQUIRE(idxSeq.size() == 6); -} - -TEST_CASE("Make Index Sequence", "[FuncUtil]") -{ - auto idxSeq = pymol::make_index_sequence<10>(); - static_assert(idxSeq.size() == 10, "Incorrect integer sequence size"); - REQUIRE(idxSeq.size() == 10); -} - -TEST_CASE("Index Sequence For", "[FuncUtil]") -{ - auto idxSeq = pymol::index_sequence_for(); - static_assert(idxSeq.size() == 3, "Incorrect integer sequence size"); - REQUIRE(idxSeq.size() == 3); -} - -constexpr int constexprFunc() -{ - return 42; -}; - -TEST_CASE("Invoke", "[FuncUtil]") -{ - auto returnValue = constexprFunc(); - auto returnValue2 = pymol::invoke(constexprFunc); - static_assert(std::is_same::value, ""); - static_assert(std::is_same::value, ""); - static_assert(constexprFunc() == 42, "Incorrect result"); - REQUIRE(std::is_same::value); - REQUIRE(std::is_same::value); - REQUIRE(constexprFunc() == 42); - REQUIRE(pymol::invoke(constexprFunc) == 42); -} - -int applyme(std::string& s, int, float) -{ - return 42; -} - -TEST_CASE("Apply", "[FuncUtil]") -{ - std::string s{"Hello World"}; - auto value = pymol::apply(applyme, std::forward_as_tuple(s, 100, 3.14f)); - REQUIRE(value == 42); -} diff --git a/layerCTest/Test_Result.cpp b/layerCTest/Test_Result.cpp index 6187f06ec..40d450253 100644 --- a/layerCTest/Test_Result.cpp +++ b/layerCTest/Test_Result.cpp @@ -21,7 +21,7 @@ TEST_CASE("Result simple", "[Result]") template static -pymol::Result> sum(T i, U j) +pymol::Result> sum(T i, U j) { return i + j; } diff --git a/layerCTest/Test_type_traits.cpp b/layerCTest/Test_type_traits.cpp index 578596ffc..e4161462a 100644 --- a/layerCTest/Test_type_traits.cpp +++ b/layerCTest/Test_type_traits.cpp @@ -12,17 +12,17 @@ TEST_CASE("reshape", "[type_traits]") f3array* foo = shaped; static_assert(std::is_same::value, ""); - REQUIRE(pymol::equal(shaped[0], shaped[0] + 3, flat + 0)); - REQUIRE(pymol::equal(shaped[1], shaped[1] + 3, flat + 3)); + REQUIRE(std::equal(shaped[0], shaped[0] + 3, flat + 0)); + REQUIRE(std::equal(shaped[1], shaped[1] + 3, flat + 3)); } TEST_CASE("flatten", "[type_traits]") { float shaped[2][3] = {{1.f, 2.f, 3.f}, {4.f, 5.f, 6.f}}; const float* flat = pymol::flatten(shaped); - REQUIRE(pymol::equal(shaped[0], shaped[0] + 3, flat + 0)); - REQUIRE(pymol::equal(shaped[1], shaped[1] + 3, flat + 3)); + REQUIRE(std::equal(shaped[0], shaped[0] + 3, flat + 0)); + REQUIRE(std::equal(shaped[1], shaped[1] + 3, flat + 3)); auto* shaped_ptr = shaped; float* flat_from_ptr = pymol::flatten(shaped_ptr); - REQUIRE(pymol::equal(flat, flat + 6, flat_from_ptr)); + REQUIRE(std::equal(flat, flat + 6, flat_from_ptr)); }