Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2004

Tip: Looking for answers? Try searching our database.

error C2912: explicit specialization; ... is not a specialization of a function template

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JohnPantango@hotmail.com - 07 May 2004 23:19 GMT
Can anyone give me a simple work around to fix this compiler error on VC7.1

....cpp(23) : error C2912: explicit specialization; 'bool Equal<_F32>(const
_F32::type,const _F32::type)' is not a specialization of a function template

For this code:

template< class T >
inline bool Equal( const typename T::type v0,
                  const typename T::type v1 )
{
    return v0 == v1;
}

template<>
inline bool Equal< _F32 >( const _F32::type v0, // error occurs at this line

                          const _F32::type v1 )
{
    return fabs( v0 - v1 ) < _F32::epsilon;
}

EnderJSC
pjakobse - 08 May 2004 19:30 GMT
> Can anyone give me a simple work around to fix this compiler error on VC7.1
>
[quoted text clipped - 19 lines]
>
> EnderJSC
If you change 'typename T::type' in your main template it removes the
error and give a  template function which is a lot easier to use ie:

    template< class T >
    inline bool Equal( const T v0,
              const T v1 )
    {
    return v0 == v1;
    }

    template<>
    inline bool Equal( const _F32::type v0,
              const _F32::type v1 )
    {
    return fabs( v0 - v1 ) < _F32::epsilon;
    }

Now the compiler can deduct the template type for most cases so you can
just write:
    int a=1;
    int b=2;
    cout << Equal(a,b) << endl; // Uses general template
    _F32::type c=1;
    _F32::type d=2;
    cout << Equal(c,d) << endl; // Uses specialization

PJakobse

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.