Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 989907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:51:57+00:00 2026-05-16T05:51:57+00:00

Can anyone help me with this code. I’m trying to specialise a method. At

  • 0

Can anyone help me with this code. I’m trying to specialise a method. At the moment it doesn’t work with one specialisation (1) but I’d like to ultimately have lots of specialisations (2, 3, 4, 5 etc)

class X
{
public:

    // declaration
    template< int FLD >
    void set_native( char *ptr, unsigned int length );

    // specialisations

    template<> void set_native< 1 >( char *ptr, unsigned int length )
    {
    }

};

The error messages I’m getting are..

x.cpp:13: error: explicit specialization in non-namespace scope ‘class X’
x.cpp:13: error: template-id ‘set_native<1>’ for ‘void set_native(char*, unsigned int)’ does not match any template declaration
x.cpp:13: error: invalid function declaration

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:51:57+00:00Added an answer on May 16, 2026 at 5:51 am

    As Benoit proposed, you have to specialize the member function in the surrounding namespace:

    struct X {
        template<int N> void f() {}
    };
    
    template<> void X::f<1>() {} // explicit specialization at namespace scope
    

    This is because of §14.7.3 (C++03):

    An explicit specialization shall be declared in the namespace of which the template is a member, or, for member templates, in the namespace of which the enclosing class or enclosing class template is a member.

    VC however doesn’t conform to the standard in that regard and thus creates some portability headaches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help me trying to find out why this doesn't work. The brushes
I got this code in VB. and it doesn't do anything.Can anyone help me
Can anyone help me figure out whats wrong with this piece of xaml code?
can anyone help me with this issue? i tried it but the frame of
Can anyone help me with this code snippet: -(void) updateData:(NSString*)value1:(NSString*)value2 { sqlite3* database; databaseName
Can anyone help me with this code as I am a newbie in Java.
Can anyone help me change this code back to a simple for loop? public
Can anyone help me debug this program? The following is server code : package
Can anyone help me to improve this code? I want to delete array if
Can anyone help me figure out how I could simplify this code, without using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.