Browse Source

refactor: move WithDefault::operator T to impl file

Sam Jaffe 2 years ago
parent
commit
0e3ad59a3d
2 changed files with 18 additions and 8 deletions
  1. 2 8
      include/program_args/arguments.h
  2. 16 0
      include/program_args/arguments_impl.hpp

+ 2 - 8
include/program_args/arguments.h

@@ -218,14 +218,8 @@ template <typename B, typename V>
 struct Arguments<Impl>::WithDefault {
   B impl;
   V default_value;
-  template <typename T> operator T() const {
-    if (impl) { return impl; }
-    if constexpr (std::is_invocable_r<T, V>{}) {
-      return T(default_value());
-    } else {
-      return T{default_value};
-    }
-  }
+
+  template <typename T> operator T() const;
 };
 
 }

+ 16 - 0
include/program_args/arguments_impl.hpp

@@ -162,6 +162,22 @@ template <typename Impl> bool Arguments<Impl>::Option::primed() const {
 
 namespace program {
 
+template <typename Impl>
+template <typename B, typename V>
+template <typename T>
+Arguments<Impl>::WithDefault<B, V>::operator T() const {
+  if (impl) { return impl; }
+  if constexpr (std::is_invocable_r<T, V>{}) {
+    return T(default_value());
+  } else {
+    return T{default_value};
+  }
+}
+
+}
+
+namespace program {
+
 template <typename Impl>
 Arguments<Impl>::Arguments(int argc, char const * const * const argv) {
   Impl generator;