Re: Explicitly specializing std::min() on VC++ 2005 Express Edition

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Victor Bazarov" <v.Abazarov@xxxxxxxxxxxx> schrieb im Newsbeitrag
news:f1al1r$m1m$1@xxxxxxxxxxxxxxxxxx

Did you include the header where the 'std::min' template is actually
defined? Unless the compiler knows that 'std::min' is a template, it
cannot allow you to specialise it.

Yes, I did. Here's the complete code I am using:

#include <algorithm> // Defines std::min().
#include <cstring> // Defines std::strcmp().

namespace std
{
template <> inline const char*& min<>
( const char*& a, const char*& b )
{
return std::strcmp( a, b ) < 0 ? a : b;
}
}

int main()
{
return 0;
}

I also tried different signatures, like 'const char* min( const char* a,
const char* b )', but those gave me the same error code.

--
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com - The Creators of Toilet Tycoon
http://www.anvil-soft.de - Die Macher des Klomanagers


.



Relevant Pages

  • not being linked
    ... //util.h contains some usefull utility functions. ... template ... inline void printElements (const T& col, const char* pc="") ... Compiler: Default compiler ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Explicitly specializing std::min() on VC++ 2005 Express Edition
    ... Unless the compiler knows that 'std::min' is a template, ... cannot allow you to specialise it. ... like 'const char* min(const char* ...
    (microsoft.public.vc.language)
  • Re: Calling C functions from Forth
    ... I don't know yet whether pForth will be the final ... The C compiler I used was GCC. ... int strncmp (const char* str1, const char* str2, size_t num) ... stack, create the frame for C, and call the function. ...
    (comp.lang.forth)
  • Re: a few doubts!
    ... the warning messages are diagnostics. ... >> So what C compiler did you use that produced this incorrect messages? ... That causes string literals to be treated as "const char*" rather than ...
    (comp.lang.c)
  • Re: A doubly linked-list in C
    ... compiler gets there differently. ... you undefined behaviour. ... Use const char *p. ... that's the reason string literals aren't const. ...
    (comp.lang.c)