how to get outer class name from inner enum <p>basicly what i want to do is written in code. so , is there a way with templates or with something else get outer class name in global function ? is there a way to get this code work?</p> <pre><code>#include &lt;iostream&gt; class A { public: enum class B { val1, val2 }; typedef B InnerEnum; static void f(InnerEnum val) { std::cout &lt;&lt; static_cast&lt;int&gt;(val); } }; template &lt;typename T1&gt; void f(typename T1::InnerEnum val) { T1::f(val); } int main() { A::InnerEnum v = A::InnerEnum::val1; f(v); return 0; } </code></pre>