Skip to content

Instantly share code, notes, and snippets.

@kaworu
Created November 18, 2013 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaworu/7535674 to your computer and use it in GitHub Desktop.
Save kaworu/7535674 to your computer and use it in GitHub Desktop.
/*
* stdmax.cpp
*
*/
#define __STDC_CONSTANT_MACROS 1
#include <stdint.h>
#include <iostream>
int
main(int argc, char *argv[])
{
uint64_t u = 42;
std::cout << std::max(u, UINT64_C(1)) << std::endl;
return (0);
}
@kaworu
Copy link
Author

kaworu commented Nov 18, 2013

[alex@dragonfly ~] % uname -a
DragonFly dragonfly 3.5-DEVELOPMENT DragonFly v3.5.0.1265.gc05746-DEVELOPMENT #0: Sun Oct 27 13:00:39 UTC 2013     root@pkgbox64.dragonflybsd.org:/usr/obj/usr/src/sys/X86_64_GENERIC  x86_64
[alex@dragonfly ~] % g++ stdmax.cpp 
stdmax.cpp: In function 'int main(int, char**)':
stdmax.cpp:16:38: error: no matching function for call to 'max(uint64_t&, long long unsigned int)'
stdmax.cpp:16:38: note: candidates are:
In file included from /usr/include/c++/4.7/bits/char_traits.h:41:0,
                 from /usr/include/c++/4.7/ios:41,
                 from /usr/include/c++/4.7/ostream:40,
                 from /usr/include/c++/4.7/iostream:40,
                 from stdmax.cpp:8:
/usr/include/c++/4.7/bits/stl_algobase.h:210:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
/usr/include/c++/4.7/bits/stl_algobase.h:210:5: note:   template argument deduction/substitution failed:
stdmax.cpp:16:38: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int')
In file included from /usr/include/c++/4.7/bits/char_traits.h:41:0,
                 from /usr/include/c++/4.7/ios:41,
                 from /usr/include/c++/4.7/ostream:40,
                 from /usr/include/c++/4.7/iostream:40,
                 from stdmax.cpp:8:
/usr/include/c++/4.7/bits/stl_algobase.h:254:5: note: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
/usr/include/c++/4.7/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
stdmax.cpp:16:38: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment