This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
namespace detail { | |
template <typename T, typename> | |
class is_complete_helper { | |
template <typename U> | |
static auto check(U*) -> std::integral_constant<bool, sizeof(U) >= 0>; | |
static std::false_type check(...); | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <initializer_list> | |
#include <numeric> | |
template <typename E> | |
struct flags { | |
using type = std::underlying_type_t<E>; | |
constexpr flags(std::initializer_list<E> values) : | |
value{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <tuple> | |
template <typename> struct function_traits; | |
template <typename R, typename ... A> | |
struct function_traits<R(A ...)> { | |
using result = R; | |
using args = std::tuple<A ...>; | |
template <std::size_t I> using arg = typename std::tuple_element_t<I, args>; | |
constexpr static auto arity = sizeof ... (A); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <unsigned Precision = 16> | |
class FastLog { | |
public: | |
static constexpr double log(double x) { | |
return instance().fast_log(x); | |
} | |
private: | |
static constexpr size_t TableSize = 1 << Precision; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.Intent; | |
import android.content.IntentFilter; | |
import android.net.Uri; | |
import android.os.Handler; | |
import android.os.Message; | |
import android.util.Log; | |
import java.util.ArrayList; | |
import java.util.HashMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ANB_SDK_DIR = #Set path to Android SDK | |
ANB_BUILD_TOOLS_VERSION = $(shell ls $(ANB_SDK_DIR)/build-tools | sort -n | tail -1) | |
ANB_PLATFORM = $(shell ls $(ANB_SDK_DIR)/platforms | sort -n | tail -1) | |
ANB_KEYSTORE = ~/.android/debug.keystore | |
ANB_KEYSTORE_PASS = android | |
ANB_KEY = androiddebugkey | |
ANB_SOURCE_COMPATIBILITY = 1.7 | |
ANB_TARGET_COMPATIBILITY = 1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FilterInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
public class CachingInputStream extends FilterInputStream { | |
private final OutputStream mOut; | |
public CachingInputStream(InputStream in, OutputStream out) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <tuple> | |
#include <stdexcept> | |
template <typename T, size_t I> | |
struct multi_base : public T {}; | |
template <typename, typename ...> struct function_array; | |
template <size_t ... Is, typename ... Fs> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LooperPool { | |
private final ArrayList<Handler> mIdleHandlers = new ArrayList<Handler>(); | |
public void addTask(final Runnable task) { | |
Handler handler = null; | |
synchronized (mIdleHandlers) { | |
if (!mIdleHandlers.isEmpty()) { | |
handler = mIdleHandlers.remove(mIdleHandlers.size() - 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
template <typename T> | |
consteval auto underlying_cast(T val, std::enable_if_t<std::is_enum_v<T>>* = 0) noexcept { | |
return static_cast<std::underlying_type_t<T>>(val); | |
} | |
/* | |
Usage: |
NewerOlder