]> git.sesse.net Git - stockfish/blobdiff - src/misc.h
Fix ambiguity between clamp implementations
[stockfish] / src / misc.h
index b1385c2f80a134c9c443e3ac7aa5dd6390687736..e0e0e98be8357cee894b2133ead6f654c0abc3f4 100644 (file)
 #include "types.h"
 
 const std::string engine_info(bool to_uci = false);
+const std::string compiler_info();
 void prefetch(void* addr);
 void start_logger(const std::string& fname);
+void* aligned_ttmem_alloc(size_t size, void*& mem);
 
 void dbg_hit_on(bool b);
 void dbg_hit_on(bool c, bool b);
@@ -62,6 +64,14 @@ std::ostream& operator<<(std::ostream&, SyncCout);
 #define sync_cout std::cout << IO_LOCK
 #define sync_endl std::endl << IO_UNLOCK
 
+namespace Utility {
+
+/// Clamp a value between lo and hi. Available in c++17.
+template<class T> constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
+  return v < lo ? lo : v > hi ? hi : v;
+}
+
+}
 
 /// xorshift64star Pseudo-Random Number Generator
 /// This class is based on original code written and dedicated