下面的代码:
#include <cstddef>
using std::size_t;
int hOccupy(int* numB, const void* f, int bS, size_t dyn);
template <class T>
inline int hOccupy(int* numB, T f, int bS, size_t dyn) {
return hOccupy(numB, reinterpret_cast<const void*>(f), bS, dyn);
}
int main(int argc, char *argv[]) {
decltype(&hOccupy) f = &hOccupy;
}
Run Code Online (Sandbox Code Playgroud)
给出错误:
error: reference to overloaded function could not be resolved; did you mean to call it?
Run Code Online (Sandbox Code Playgroud)
谁能建议这里出了什么问题以及如何克服它?
我正在用C#编写一个看起来像这样的应用程序.
public partial class MainForm : Form
{
WICForm Frm = new WICForm();
public MainForm(){}
}
Run Code Online (Sandbox Code Playgroud)
其中MainForm和WICForm是同一应用程序中的两种不同形式.但是当我运行应用程序时,我在创建WICForm的新实例Frm时遇到上述错误.可能是什么原因?
我有以下代码,其中std :: tuple可与nullptr一起使用,但不适用于NULL。
#include <iostream>
#include <tuple>
int main()
{
tuple<int*> t1, t2;
t1 = std::make_tuple(NULL);
t2 = std::make_tuple(nullptr);
}
Run Code Online (Sandbox Code Playgroud)
当使用C ++ 11编译时,该代码在使用nullptr时有效,但是在使用NULL的情况下会出现以下错误。
In file included from tuple.cpp:2:
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/tuple:447:8: error: assigning to 'int *' from incompatible type 'long'
= std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/tuple:575:36: note: in instantiation of function template specialization 'std::_Tuple_impl<0, int *>::operator=<long>' requested here
static_cast<_Inherited&>(*this) = std::move(__in);
^
tuple.cpp:13:8: note: in instantiation of function template specialization 'std::tuple<int *>::operator=<long, void>' requested here
t1 = std::make_tuple(NULL);
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
在这里,NULL的类型是long …