Skip to content

Commit

Permalink
use C++17 and std::clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
wojdyr committed Jan 21, 2025
1 parent 9c2a7f4 commit 7bb0278
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ add_library(gemmi::headers ALIAS gemmi_headers)
target_include_directories(gemmi_headers INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_compile_features(gemmi_headers INTERFACE cxx_std_14)
target_compile_features(gemmi_headers INTERFACE cxx_std_17)
set_target_properties(gemmi_headers PROPERTIES EXPORT_NAME headers)

add_library(gemmi_cpp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEMMI can help if you work with:
* crystallographic symmetries,
* or if you just read and write CIF/STAR files (where C=Crystallographic).

GEMMI is a C++ library (currently, C++14) accompanied by:
GEMMI is a C++ library (currently, C++17) accompanied by:

* command-line [tools](https://gemmi.readthedocs.io/en/latest/utils.html),
* Python bindings,
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gemmi is open-source (MPL_) and portable -- it runs on Linux, Windows,
MacOS and even inside a web browser if compiled to WebAssembly
(`here <https://project-gemmi.github.io/wasm/>`__ and
`here <https://www.npmjs.com/package/mtz>`__).
It is written in C++14, with Python (3.8+) bindings,
It is written in C++17, with Python (3.8+) bindings,
and with partial C and Fortran 2003 interface.

.. _MPL: https://www.mozilla.org/en-US/MPL/2.0/
Expand Down
2 changes: 1 addition & 1 deletion include/gemmi/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct Vec3_ {
return dot(o) / std::sqrt(length_sq() * o.length_sq());
}
Real angle(const Vec3_& o) const {
return std::acos(std::max(-1., std::min(1., cos_angle(o))));
return std::acos(std::clamp(cos_angle(o), -1., 1.));
}
bool approx(const Vec3_& o, Real epsilon) const {
return std::fabs(x - o.x) <= epsilon &&
Expand Down
2 changes: 1 addition & 1 deletion include/gemmi/modify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ template<class T> void assign_b_iso(T& obj, float b_min, float b_max) {
assign_b_iso(child, b_min, b_max);
}
template<> inline void assign_b_iso(Atom& atom, float b_min, float b_max) {
atom.b_iso = std::min(std::max(atom.b_iso, b_min), b_max);
atom.b_iso = std::clamp(atom.b_iso, b_min, b_max);
}

/// Remove anisotropic ADP
Expand Down
2 changes: 1 addition & 1 deletion prog/set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct Clamp {
if (xmin == xmax)
*x = xmin;
else
*x = std::min(std::max(*x, xmin), xmax);
*x = std::clamp(*x, xmin, xmax);
}
};

Expand Down

0 comments on commit 7bb0278

Please sign in to comment.