在做自己的程序時候,出現這個錯誤。
usr/include/c++/9/bits/shared_ptr.h:106:8: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
106 | using _Constructible = typename enable_if<
| ^~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(const false_type&, Y*) [with Y = const char; T = cv::Formatted; std::false_type = std::integral_constant<bool, false>]’:
/usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:103:57: required from ‘cv::Ptr<T>::Ptr(Y*) [with Y = const char; T = cv::Formatted]’
/home/xiaopeng/webserver-test/epoll.cpp:154:38: required from here
/usr/include/c++/9/bits/shared_ptr.h:129:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Tp>&) [with _Tp = cv::Formatted]’
129 | shared_ptr(const shared_ptr&) noexcept = default;
| ^~~~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:129:18: note: no known conversion for argument 1 from ‘const char*’ to ‘const std::shared_ptr<cv::Formatted>&’
129 | shared_ptr(const shared_ptr&) noexcept = default;
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:127:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr() [with _Tp = cv::Formatted]’
127 | constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { }
| ^~~~~~~~~~
/usr/include/c++/9/bits/shared_ptr.h:127:17: note: candidate expects 0 arguments, 1 provided
make[2]: *** [CMakeFiles/webserver1.dir/build.make:76:CMakeFiles/webserver1.dir/epoll.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:83:CMakeFiles/webserver1.dir/all] 错误 2
make: *** [Makefile:91:all] 错误 2
找了半天,發現是print和printf的原因,
print是opencv自帶的方法,我的程序用了oepncv
using namespace cv;
所以沒有報錯。但是編譯的時候才會出現問題。
因爲我要用的是prtinf
std::printf()
就這一處沒使用std。結果搞了半天。
再次提醒,不要省略std。
尤其是在用notepad等編程序,儘量給所有變量和函數都綁定類,那麼即使出現bug,也能快速定位。
在做自己的程序時候,出現這個錯誤。usr/include/c++/9/bits/shared_ptr.h:106:8: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 106 | using _Constructible = typename enable_if< | ^~~~~~~~~~~~~~/usr/local/include/opencv4/opencv2/c
struct enable_if { typedef T type; };
由上可知,只有当第一个模板参数为true时,enable_if会包含一个type=T的公有成员,否则没有该公有成员。
#include <type_t
今日在阅读LLVM相关源码时(如下所示),遇到了enable_if这个概念,以前从没有遇到过,这里做个小记。
/*----------llvm/include/llvm/ADT/Hashing.h------------*/
/// \brief Compute a hash_code for any integer value.
/// Note that this funct
Kaitai Struct:C ++ / STL的运行时库
该库使用STL实现了C ++的Kaitai Struct API。
Kaitai Struct是一种声明性语言,用于描述文件或内存中布置的各种二进制数据结构:即二进制文件格式,网络流包格式等。
进一步阅读:
最近刷题总出现一些奇怪的问题,决定开始写blog记录一下~
错误:no type named ‘iterator_category’ in ‘struct snode’
错误代码:
struct snode
double x;
double y;
double distance(snode n1, snode n2)
return sqrt(pow(n1.x-n2.x,2.0)+po...
Kaitai Struct:Go的运行时库
该库实现了用于Go的Kaitai Struct API。
Kaitai Struct是一种声明性语言,用于描述文件或内存中布置的各种二进制数据结构:即二进制文件格式,网络流包格式等。
进一步阅读:
特此免费授予获得该软件和相关文档文件(“软件”)副本的任何人无限制地处理软件的权利,包括但不限于使用,复制,修改,合并的权利,发布,分发,再许可和/或出售本软件的副本,并允许具备软件的人员这样做,但须满足以下条件:
以上版权声明和此许可声明应包含在本软件的所有副本或大部分内容中。
本软件按“原样”提供,不提供任何形式的明示或暗示担保,包括但不限于对适销性,特定目的的适用性和非侵权性的担保。 无论是由于软件,使用或其他方式产生的,与之有关或与之有关的合同,侵权或其他形式的任何索赔,损
TinyString(size_t n, char c);
TinyString(const char* s, size_t n=0);
TinyString(const std::string& str);
template<size_t K>
TinyString& operator = (const TinyString<K>& str);
TinyString& operator = (const std::string& str);
TinyString& operator = (const char* s);
TinyString& operator = (char ch);
template<size_t K>
TinyString& operator += (const TinyString<K>& other);
bool empty() const { return len == 0; }
int size() const { return len; }
int obj_size() const { return sizeof(*this); }
const char* GetData()const { return buffer; }
const char* c_str()const { return buffer; }
bool operator == (const TinyString& other) const;
bool operator < (const TinyString& other) const;
operator std::string() const; //转为字符串
std::string ToString()const; //转为字符串
template<size_t K>
friend std::ostream & operator<< (std::ostream& os, const TinyString<K>& str);
template<size_t K, size_t L>
friend bool operator == (const TinyString<K>& s1, const TinyString<L>& s2);
//......
uint8_t len;
char buffer[N-1];
typedef TinyString<8> TinyStr8;
typedef TinyString<16> TinyStr16;
typedef TinyString<32> TinyStr32;
typedef TinyString<1024> TinyStr1K;
typedef TinyString<4096> TinyStr4K;
关于这个错误,我自己的情况是thread函数形参有&引用传值,例如:
void thread_test(vector<int> &test_vec),编译就会报错,去掉&就可以了,查到的其他方式并没有能解决这个问题,不知道是因为什么。
driverOptions.put_propertyTree('ColorSource', 'Visible Colors') Boost.Python.ArgumentError: Python argument types in PropertyTree.put_propertyTree(PropertyTree, str, str) did not match C++ signature: put_propertyTree(class boost::property_tree::basic_ptree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > item_path, class boost::property_tree::basic_ptree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > child_tree)如何解决这个问题
这个错误是由于Python调用C++函数时,传递的参数类型和C++函数的参数类型不匹配导致的。具体而言,Python中的str类型和C++中的std::string类型不兼容。
要解决这个问题,你需要将Python的str类型转换为C++的std::string类型。可以使用以下代码实现:
```python
import ctypes
def to_std_string(py_string):
return ctypes.c_char_p(py_string.encode('utf-8')).value.decode('utf-8')
driverOptions.put_propertyTree(to_std_string('ColorSource'), to_std_string('Visible Colors'))
在这个代码中,to_std_string()函数将Python的str类型转换为C++的std::string类型。在调用put_propertyTree()函数时,我们使用to_std_string()将Python的字符串参数转换为C++字符串参数,从而解决了类型不匹配的问题。