From e37b250d4d3d483e708db60ac9774342fd4b9700 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sat, 11 Jun 2016 14:24:03 +0100 Subject: [PATCH] Use correct type of std::map::count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling Ardour commit ec8a4de01596c162c1529f3021dfc432bf66dfe8 with GCC 6.1.1 (on Fedora 24) gave this build failure: In file included from /home/sam/ardour/libs/lua/LuaBridge/LuaBridge.h:154:0, from ../tools/luadevel/devel.cc:16: /home/sam/ardour/libs/lua/LuaBridge/detail/Namespace.h: In instantiation of ‘luabridge::Namespace::Class > luabridge::Namespace::beginStdMap(const char*) [with K = std::__cxx11::basic_string; V = std::__cxx11::basic_string]’: ../tools/luadevel/devel.cc:89:60: required from here /home/sam/ardour/libs/lua/LuaBridge/detail/Namespace.h:1666:30: error: no matches converting function ‘count’ to type ‘void (class std::map, std::__cxx11::basic_string, std::less >, std::allocator, std::__cxx11::basic_string > > >::*)()’ .addFunction ("count", (void (LT::*)())<::count) ^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/6.1.1/map:61:0, from /home/sam/ardour/libs/lua/LuaBridge/LuaBridge.h:45, from ../tools/luadevel/devel.cc:16: /usr/include/c++/6.1.1/bits/stl_map.h:1131:2: note: candidates are: template decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = std::__cxx11::basic_string; _Tp = std::__cxx11::basic_string; _Compare = std::less >; _Alloc = std::allocator, std::__cxx11::basic_string > >] count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) ^~~~~ /usr/include/c++/6.1.1/bits/stl_map.h:1125:7: note: std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::__cxx11::basic_string; _Tp = std::__cxx11::basic_string; _Compare = std::less >; _Alloc = std::allocator, std::__cxx11::basic_string > >; std::map<_Key, _Tp, _Compare, _Alloc>::size_type = long unsigned int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::__cxx11::basic_string] count(const key_type& __x) const ^~~~~ Casting std::map::count to the correct type instead of a fake void() type fixes the compile failure. --- libs/lua/LuaBridge/detail/Namespace.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/lua/LuaBridge/detail/Namespace.h b/libs/lua/LuaBridge/detail/Namespace.h index 79a0786d40..92aed81530 100644 --- a/libs/lua/LuaBridge/detail/Namespace.h +++ b/libs/lua/LuaBridge/detail/Namespace.h @@ -1658,12 +1658,14 @@ public: typedef std::map LT; typedef std::pair T; + typedef typename std::map::size_type T_SIZE; + return beginClass (name) .addVoidConstructor () .addFunction ("empty", <::empty) .addFunction ("size", <::size) .addFunction ("clear", (void (LT::*)())<::clear) - .addFunction ("count", (void (LT::*)())<::count) + .addFunction ("count", (T_SIZE (LT::*)(const K&) const)<::count) .addExtCFunction ("add", &CFunc::tableToMap) .addExtCFunction ("iter", &CFunc::mapIter) .addExtCFunction ("table", &CFunc::mapToTable);