]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/misc.hh
lilypond-manuals.css: edit color scheme and some spacing
[lilypond.git] / lily / include / misc.hh
index 206e74e3eae5da6de3ad169041ea8a72128103ba..174b2f4c01663be76fed63778e558d03cf708d6f 100644 (file)
 #define MISC_HH
 
 #include <cstdlib>
+using namespace std;
 
 #include "std-vector.hh"
 #include "interval.hh"
 
 double log_2 (double x);
-int intlog2 (int d);
+
+/*
+  Return the 2-log, rounded down
+*/
+template <class T>
+int
+intlog2 (T d)
+{
+  if (d <= 0)
+    error ("intlog2 with negative argument: " + ::to_string (d));
+  int i = 0;
+  while ((d != 1))
+    {
+      d /= 2;
+      i++;
+    }
+
+  assert (! (d / 2));
+  return i;
+}
 
 inline int
 sign (int i)
@@ -62,7 +82,7 @@ Real directed_round (Real f, Direction d);
 
 Real peak_around (Real epsilon, Real threshold, Real x);
 Real convex_amplifier (Real standard_x, Real increase_factor, Real x);
-std::string camel_case_to_lisp_identifier (const std::string &in);
+string camel_case_to_lisp_identifier (const string &in);
 
 #endif