--- a/pan/data-impl/groups.cc
+++ b/pan/data-impl/groups.cc
@@ -81,7 +81,14 @@
   }
 }
 
+#include <ciso646> // detect std::lib
+#ifdef _LIBCPP_VERSION
+// using libc++
+#include <algorithm>
+#else
+// using libstdc++
 #include <ext/algorithm>
+#endif
 
 void
 DataImpl :: load_newsrc (const Quark       & server,

