यदि मैं इस कोड स्निपेट में boost :: shared_ptr से std :: shared_ptr में बदलता हूं, तो मुझे लिंकर त्रुटि मिल जाएगी।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
क्या मैं गलत क्या किया? मैंने अनुमान लगाया कि स्टडी नेमस्पेस और नामस्थान को बढ़ावा देने के बीच एक संघर्ष था, लेकिन मुझे नहीं पता कि इसे कैसे ठीक किया जाए? कोई उपाय?
धन्यवाद,
चैन
वे लिंकर त्रुटियां नहीं हैं, बल्कि संकलक त्रुटियों हैं। –