在build的时候,在语句
std::string fileName = dirItr->path().filename();出现了如下的错误
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: 'initializing' : cannot convert from 'boost::filesystem3::path' to 'std::basic_string<_Elem,_Traits,_Ax>'
我有些费解怎么解决这个问题,请大家解答前来拿分
16 个解决方案
#1
std::string firstFile = boost::filesystem::path(first->name()).leaf().string();
also note that the leaf function is deprecated and is removed in Boost.Filesystem V3.
also note that the leaf function is deprecated and is removed in Boost.Filesystem V3.
#2
错误的具体内容是
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: 'initializing' : cannot convert from 'boost::filesystem3::path' to 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: 'initializing' : cannot convert from 'boost::filesystem3::path' to 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
#3
LZ用的是filesystem的V2还是V3?旧些的boost版本默认V2,最近默认V3了,是不是这个问题
#4
既然如此,那我应该怎么解决这个问题,有没有替代函数,dizuo大哥?多谢指点
#5
我觉得应该是v3的,因为我下载的是最新版的boost, 1_46
但是这个功能应该有替代的 啊
#6
filename返回的类型是path模板参数的类型。你的path的模板参数是什么类型呢?
#7
我查了一下相关的错误,就是那个c2440,应该是和类型转换相关的
而且提示了 1> No constructor could take the source type, or constructor overload resolution was ambiguous
而且提示了 1> No constructor could take the source type, or constructor overload resolution was ambiguous
#8
std::string fileName(dirItr->path().filename());这样不知道是否可以
#9
这个我不太懂啊,因为用的是boost库的东西。
前后是这样的
前后是这样的
boost::filesystem::directory_iterator dirItr ( m_path );
boost::filesystem::directory_iterator endItr;
std::string imgformat = hp.readStringParameter ( captureName + ".imageFormat" );
for ( ; dirItr != endItr; ++dirItr )
{
std::string fileName = dirItr->path().filename();
#10
我试试看,呵呵,谢谢,希望可以
#11
代码改成
报错误
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: '<function-style-cast>' : cannot convert from 'boost::filesystem3::path' to 'std::string'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
以下是boost文档中对于filename()的解释
string_type filename() const;
Returns: empty() ? string_type() : *--end()
std::string fileName = std::string (dirItr->path().filename());
报错误
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: '<function-style-cast>' : cannot convert from 'boost::filesystem3::path' to 'std::string'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
以下是boost文档中对于filename()的解释
string_type filename() const;
Returns: empty() ? string_type() : *--end()
#12
看了下源码,返回的类型是string。你#include<string>没呢?
#13
在.h里面引用了,头痛,这个问题,好可恶
求求各位高手赶快来拿分了
#14
dirItr->path().filename()
返回的是path类型的,下面是声明:
path filename() const; // returns 0 or 1 element path
要先转换成string,例如
std::string fileName = dirItr->path().filename().string();
#15
的确,zhang,差不多那么解决的
其实是filename().c_str()
然后就好了
其实是filename().c_str()
然后就好了
#16
你好,请问你代码调通了没?因为作者用的是Ubuntu10.04,opencv2.1的,都比较老了,我用的是Ubuntu13.04的,boost和libconfig都没问题了,上面的问题按照你的方法也解决了,现在编译已经没错了,错在link上面,是opencv的问题,然后现在一直没调通。。。想请你帮帮忙
#1
std::string firstFile = boost::filesystem::path(first->name()).leaf().string();
also note that the leaf function is deprecated and is removed in Boost.Filesystem V3.
also note that the leaf function is deprecated and is removed in Boost.Filesystem V3.
#2
错误的具体内容是
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: 'initializing' : cannot convert from 'boost::filesystem3::path' to 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: 'initializing' : cannot convert from 'boost::filesystem3::path' to 'std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
#3
LZ用的是filesystem的V2还是V3?旧些的boost版本默认V2,最近默认V3了,是不是这个问题
#4
既然如此,那我应该怎么解决这个问题,有没有替代函数,dizuo大哥?多谢指点
#5
我觉得应该是v3的,因为我下载的是最新版的boost, 1_46
但是这个功能应该有替代的 啊
#6
filename返回的类型是path模板参数的类型。你的path的模板参数是什么类型呢?
#7
我查了一下相关的错误,就是那个c2440,应该是和类型转换相关的
而且提示了 1> No constructor could take the source type, or constructor overload resolution was ambiguous
而且提示了 1> No constructor could take the source type, or constructor overload resolution was ambiguous
#8
std::string fileName(dirItr->path().filename());这样不知道是否可以
#9
这个我不太懂啊,因为用的是boost库的东西。
前后是这样的
前后是这样的
boost::filesystem::directory_iterator dirItr ( m_path );
boost::filesystem::directory_iterator endItr;
std::string imgformat = hp.readStringParameter ( captureName + ".imageFormat" );
for ( ; dirItr != endItr; ++dirItr )
{
std::string fileName = dirItr->path().filename();
#10
我试试看,呵呵,谢谢,希望可以
#11
代码改成
报错误
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: '<function-style-cast>' : cannot convert from 'boost::filesystem3::path' to 'std::string'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
以下是boost文档中对于filename()的解释
string_type filename() const;
Returns: empty() ? string_type() : *--end()
std::string fileName = std::string (dirItr->path().filename());
报错误
1>.\HoughTrack1.0\code\capture.cpp(100) : error C2440: '<function-style-cast>' : cannot convert from 'boost::filesystem3::path' to 'std::string'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
以下是boost文档中对于filename()的解释
string_type filename() const;
Returns: empty() ? string_type() : *--end()
#12
看了下源码,返回的类型是string。你#include<string>没呢?
#13
在.h里面引用了,头痛,这个问题,好可恶
求求各位高手赶快来拿分了
#14
dirItr->path().filename()
返回的是path类型的,下面是声明:
path filename() const; // returns 0 or 1 element path
要先转换成string,例如
std::string fileName = dirItr->path().filename().string();
#15
的确,zhang,差不多那么解决的
其实是filename().c_str()
然后就好了
其实是filename().c_str()
然后就好了
#16
你好,请问你代码调通了没?因为作者用的是Ubuntu10.04,opencv2.1的,都比较老了,我用的是Ubuntu13.04的,boost和libconfig都没问题了,上面的问题按照你的方法也解决了,现在编译已经没错了,错在link上面,是opencv的问题,然后现在一直没调通。。。想请你帮帮忙