Explicit specialization in non-namespace scope error… Desperately need help


Can somebody please help me to port the following code to <strong>GCC</strong>? I have found a lot or related questions on this site, but I just can't seem to apply suggested workarounds in my case...

typedef float MyData __attribute__ ((__vector_size__ (16))); template <typename T> class Data_T { public: template < typename U > static bool IsEqual (const T & a, const T & b) { return a == b; } //Fixed: template <> static bool IsEqual < MyData > ( const MyData & a, const MyData & b) static bool IsEqual ( const MyData & a, const MyData & b) { return true; } void TriggerProblem(const T & val) { if (!IsEqual(1.0f, val)) // Error: no matching function for call to 'Data_T<float>::IsEqual(float, const float&)' { } } };

The code to trigger the problem:

Data_T<MyData> inst; inst.TriggerProblem(1.0f);

I was getting an error <strong>error: explicit specialization in non-namespace scope 'class Data_T'</strong>, which was caused by specialization function <strong>IsEqual()</strong>, but now encountered another type of error (<strong>no matching function for call to 'Data_T::IsEqual(float, const float&)'</strong>), which seems to be caused by the <strong>__vector_size__</strong> attribute, which I can't remove. Please help...


In this case overloading should suffice instead of specializing:

template <typename T> class Data_T { public: template<typename U> static bool IsEqual(const U& a, const U& b) { return a == b; } static bool IsEqual(const MyData& a, const MyData& b) { return MyDataTypeIsEqual (a, b); } template<typename U> bool IsRangeEqual(const U& a, const U& b, const U& delta) { return (a >= b) ? (a - b <= delta) : (b - a <= delta); } bool IsRangeEqual(const MyData & a, const MyData & b, const MyData & accuracy) { return MyDataTypeIsRangeEqual (a, b, accuracy); } };

<em>Edit regarding update</em>:<br /> While for me the conversion from float to float __vector__ already fails, you seem to have a typo of:

template<typename U> static bool IsEqual(const T& a, const T& b)


template<typename U> static bool IsEqual(const U& a, const U& b)

I fixed the above code accordingly.


  • sorting 2-d array based on the first column
  • Having trouble with array being overwritten
  • C: How to return separate multiple values from function to main
  • How to put different size vectors in data.table column
  • “class template has already been declared as a non-class template”
  • Member function pointer cast, from Derived to Base class
  • Partial specialization of a class template in derived class affects base class
  • Deleting a widget from QTableView
  • Reading space separated values file in c++ error
  • multidatatrigger with multibinding in ControlTemplate.Triggers
  • Is there a parser equivalent of 'fragment' marking in ANTLR4?
  • VBA Excel, loop through variables
  • Build Successful but not running on simulator
  • $wpdb not working in file of WordPress plugin
  • RectangularRangeIndicator format like triangular using dojo
  • sending/ receiving email in Java
  • Akka Routing: Reply's send to router ends up as dead letters
  • Cannot Parse HTML Data Using Android / JSOUP
  • How to delete a row from a dynamic generate table using jquery?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • Proper way to use connect-multiparty with express.js?
  • JTable with a ScrollPane misbehaving
  • Java static initializers and reflection
  • Bitwise OR returns boolean when one of operands is nil
  • unknown Exception android
  • sending mail using smtp is too slow
  • Checking variable from a different class in C#
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • How can I use `wmic` in a Windows PE script?
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?