diff --git a/inc/smjni/java_class_table.h b/inc/smjni/java_class_table.h index 1e274a6..c4ecf5c 100644 --- a/inc/smjni/java_class_table.h +++ b/inc/smjni/java_class_table.h @@ -22,16 +22,10 @@ namespace smjni { - template - class java_class_table + namespace internal { - private: - template - static JNIEnv * tuple_forward(JNIEnv * env) - { return env; } - template - static void tuple_for_each(std::tuple &ts, Func func) + void tuple_for_each(std::tuple &ts, Func func) { int unused[] = {(func(std::get(ts)),0)...}; (void)unused; @@ -42,11 +36,15 @@ namespace smjni { typedef std::tuple...> type; }; - - class registrator + + template + decltype(auto) dependent_forward(X && val) + { return std::forward(val); } + + class class_registrator { public: - registrator(JNIEnv * env): + class_registrator(JNIEnv * env): m_env(env) {} @@ -68,13 +66,18 @@ namespace smjni JNIEnv * const m_env; }; - + } + + template + class java_class_table + { + private: struct table : public std::tuple { table(JNIEnv * env): - std::tuple(tuple_forward(env)...) + std::tuple(internal::dependent_forward(env)...) { - tuple_for_each(*this, registrator(env)); + internal::tuple_for_each(*this, internal::class_registrator(env)); } }; public: @@ -94,7 +97,7 @@ namespace smjni } template class Transform> - using transformed_type = typename tuple_transform::type; + using transformed_type = typename internal::tuple_transform::type; private: java_class_table(JNIEnv * env): m_table(env)