Posting this here because I can't figure out if the code is wrong (if it is, it has to be something really stupidly simple...) or if the error message is misleading. /** */ #include <mutex> typedef unsigned int flag_t; class Data { private: std::mutex __M_lock; flag_t __M_immune; private: template<typename T> using manip_fn = T (*)(T&, const T&) noexcept; template<typename T> inline T __raw_set_flag(T& flag, const T& bits) noexcept { T o = flag; flag |= bits; return o; } template<typename T> inline auto __raw_clr_flag(T& flag, const T& bits) noexcept { auto o = flag; flag &= ~bits; return o; } template<typename T> inline auto __raw_tgl_flag(T& flag, const T& bits) noexcept { auto o = flag; flag ^= bits; return o; } private: template<typename T> inline T __manip_flag(T& flag, T bits, T (fn)(T&, const T&)) noexcept { try { __M_lock.lock(); T o = (*fn)(flag, bits); __M_lock.unlock(); return o; } catch (...) // Should not happen, but do it without the lock { return (*fn)(flag, bits); } } template<typename T> inline T __set_flag(T& flag, const T& bits) noexcept { return __manip_flag(flag, bits, __raw_set_flag<T>); } /* template<typename T> inline T __clr_flag(T& flag, const T& bits) noexcept { return __manip_flag(flag, bits, __raw_clr_flag); } template<typename T> inline T __tgl_flag(T& flag, T bits) noexcept { return __manip_flag(flag, bits, __raw_tgl_flag); } */ public: Data() noexcept = default; Data(const Data&) noexcept = default; ~Data() noexcept = default; Data& operator=(const Data&) noexcept = default; inline flag_t set_immf(flag_t b) noexcept { return __set_flag(__M_immune, b); } inline flag_t clr_immf(flag_t b) noexcept { return __clr_flag(__M_immune, b); } inline flag_t tgl_immf(flag_t b) noexcept { return __tgl_flag(__M_immune, b); } inline flag_t immf() const throw () { return __M_immune; } inline flag_t has_immf(flag_t b) const throw () { return immf() & b; } }; >>> g++ -std=c++14 -c Data.cc Data.cc: In member function ‘T Data::__clr_flag(T&, const T&)’: Data.cc:67:37: error: ‘__raw_clr_flag’ was not declared in this scope { return __manip_flag(flag, bits, __raw_clr_flag); } ^ Data.cc: In member function ‘T Data::__tgl_flag(T&, T)’: Data.cc:72:37: error: ‘__raw_tgl_flag’ was not declared in this scope { return __manip_flag(flag, bits, __raw_tgl_flag); } ^ Data.cc: In instantiation of ‘T Data::__set_flag(T&, const T&) [with T = unsigned int]’: Data.cc:83:36: required from here Data.cc:62:54: error: no matching function for call to ‘Data::__manip_flag(unsigned int&, const unsigned int&, <unresolved overloaded function type>)’ { return __manip_flag(flag, bits, __raw_set_flag<T>); } ^ Data.cc:62:54: note: candidate is: Data.cc:44:3: note: template<class T> T Data::__manip_flag(T&, T, T (*)(T&, const T&)) __manip_flag(T& flag, T bits, T (fn)(T&, const T&)) noexcept ^ Data.cc:44:3: note: template argument deduction/substitution failed: Data.cc:62:54: note: mismatched types ‘T (*)(T&, const T&)’ and ‘unsigned int (Data::*)(unsigned int&, const unsigned int&) noexcept’ { return __manip_flag(flag, bits, __raw_set_flag<T>); } ^ Data.cc:62:54: note: could not resolve address from overloaded function ‘__raw_set_flag<unsigned int>’ I don't understand why it thinks there's a type mismatch. (Unless, as I noted above, its something stupid...). Version is 4.9.2. Thanks! --Mike