Если в этом фрагменте кода перейти от boost :: shared_ptr к std :: shared_ptr, я получу ошибку компоновщика.
#include <iostream>
#include <sstream>
#include <iterator>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <numeric>
#include <boost/assign.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/test/included/unit_test.hpp>
#include <boost/test/included/unit_test_framework.hpp>
#include <boost/bind.hpp>
//using namespace std;
//using namespace boost;
using std::string;
using std::ostringstream;
using namespace boost::assign;
using namespace boost::unit_test;
template<typename T> string to_string( T data ) { ostringstream ost; ost << data; return ost.str(); }
class TwoStringMasks {
public:
string shortestCommon( string s1, string s2 ) {
//if( s1.find( "*" ) != 0 ||
return "";
}
};
class two_string_masks_test {
public:
void test_case_one() {
string str = "TOPCODER*";
BOOST_CHECK_EQUAL( str.find( "*" ), str.length() - 2 );
}
};
test_suite* init_unit_test_suite( int argc, char* argv[] ) {
boost::shared_ptr<two_string_masks_test> tester( new two_string_masks_test );
framework::master_test_suite().add(
BOOST_TEST_CASE( boost::bind( &two_string_masks_test::test_case_one, tester ) ) );
return 0;
}
Ошибка:
Error 12 error C2784: 'T *boost::get_pointer(T *)' : could not deduce template argument for 'T *' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 10 error C2784: 'T *boost::get_pointer(const std::auto_ptr<_Ty> &)' : could not deduce template argument for 'const std::auto_ptr<_Ty> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 11 error C2784: 'T *boost::get_pointer(const std::auto_ptr<_Ty> &)' : could not deduce template argument for 'const std::auto_ptr<_Ty> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 8 error C2784: 'T *boost::get_pointer(const boost::shared_ptr<X> &)' : could not deduce template argument for 'const boost::shared_ptr<X> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 9 error C2784: 'T *boost::get_pointer(const boost::shared_ptr<X> &)' : could not deduce template argument for 'const boost::shared_ptr<X> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 6 error C2784: 'T *boost::get_pointer(const boost::scoped_ptr<T> &)' : could not deduce template argument for 'const boost::scoped_ptr<T> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 7 error C2784: 'T *boost::get_pointer(const boost::scoped_ptr<T> &)' : could not deduce template argument for 'const boost::scoped_ptr<T> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 13 error C2784: 'T *boost::get_pointer(const boost::reference_wrapper<T> &)' : could not deduce template argument for 'const boost::reference_wrapper<T> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 14 error C2784: 'T *boost::get_pointer(const boost::reference_wrapper<T> &)' : could not deduce template argument for 'const boost::reference_wrapper<T> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 2 error C2784: 'optional<T>::pointer_type boost::get_pointer(boost::optional<T> &)' : could not deduce template argument for 'boost::optional<T> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 3 error C2784: 'optional<T>::pointer_type boost::get_pointer(boost::optional<T> &)' : could not deduce template argument for 'boost::optional<T> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 4 error C2784: 'optional<T>::pointer_const_type boost::get_pointer(const boost::optional<T> &)' : could not deduce template argument for 'const boost::optional<T> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Error 5 error C2784: 'optional<T>::pointer_const_type boost::get_pointer(const boost::optional<T> &)' : could not deduce template argument for 'const boost::optional<T> &' from 'std::tr1::shared_ptr<_Ty>' c:\program files\boost\boost_1_44\boost\bind\mem_fn_template.hpp 40 1 NET Report
Что я сделал не так? Я догадывался, что существует конфликт между пространством имен STD и пространством имен Boost, но я не знаю, как это исправить? Любая идея?
Спасибо
Чан