1

suppose I have a template class

template<typename T>
struct Foo { 
    struct Bar; 
};

specializing Foo<int>::Bar

template<>
struct Foo<int>::Bar {
    struct Private; // I want to implement this in .cc for its compile unit use only
}

to implement Private in .cc file

// template<>
struct Foo<int>::Bar::Private {...};

without template<>, it shows "too few template-parameter-lists",

with template<>, it shows explicit specialization of non-template Foo<int>::Bar::Private I also tried alias Foo<int> and it doesn't work either.

is it possible to implement Private separated from its declaration?

7
  • Implement template in a new local header file Commented Jan 9 at 8:45
  • it shows "too few template-parameter-lists" Cannot reproduce. Commented Jan 9 at 9:08
  • @n.m.couldbeanAI: msvc complains without Demo and others with Demo Commented Jan 9 at 9:12
  • And so, with conditiona MACRO, it "works" Demo. Commented Jan 9 at 9:15
  • 1
    Hmm looks like an MSVC bug for me. Bar is a member of a template one can specialize. Private is not a member of a template so there is nothing to specialize. Commented Jan 9 at 9:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.