Skip to content

Instantly share code, notes, and snippets.

@kaworu
Created November 18, 2013 22:32
Show Gist options
  • Save kaworu/7536568 to your computer and use it in GitHub Desktop.
Save kaworu/7536568 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[])
{
uintmax_t u = 42;
std::cout << std::max(u, UINTMAX_C(1)) << std::endl;
return (0);
}
@kaworu
Copy link
Author

kaworu commented Nov 18, 2013

[alex@dragonfly ~] % g++ stdmax_with_uintmax_t.cpp
stdmax_with_uintmax_t.cpp: In function 'int main(int, char**)':
stdmax_with_uintmax_t.cpp:16:39: error: no matching function for call to 'max(uintmax_t&, long long unsigned int)'
stdmax_with_uintmax_t.cpp:16:39: 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_with_uintmax_t.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_with_uintmax_t.cpp:16:39: 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_with_uintmax_t.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_with_uintmax_t.cpp:16:39: 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