开发者

"unresolved overloaded function type" when calling templated function from boost::thread

开发者 https://www.devze.com 2023-03-10 07:28 出处:网络
I\'m attempting to implement quicksort in-place, using boost\'s threading facility.Unfortunately I\'m getting an error about \"\", when my function is not overloaded.Code follows:

I'm attempting to implement quicksort in-place, using boost's threading facility. Unfortunately I'm getting an error about "", when my function is not overloaded. Code follows:

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <boost/thread.hpp>

template<typename T>
void quicksortInPlace(std::vector<T> &array,
                      size_t left,
                      size_t right,
                      size_t pivot)
{
    size_t storeIndex = left;
    // ...
    if (left < storeIndex)
    {
        boost::thread lessThread(quicksortInPlace,
                                 array,
                                 left+0,
                                 storeIndex-1,
                                 storeIndex-1);
        lessThread.join();
    }
    if (right > storeIndex)
    {
        boost::thread moreThread(quicksortInPlace,
                                 array,
                                 storeIndex+1,
                                 right+0,
                                 storeIndex+1);
        moreThread.join();
    }

}


int main()
{
    std::vector<std::string> stuff;
    stuff.push_back("two");
    stuff.push_back("one");
    size_t left  = 0;
    size_t right = 1;
    size_t pivot = 0;
    quicksortInPlace(stuff,left,right,pivot);
    return 0;
}

I'm getting the following compilation errors (using stlfilt to clean up g++ output: gfilt -width:o main.cpp)

BD Software STL Message Decryptor v3.10 for gcc 2/3/4
main.cpp: In function ‘void quicksortInPlace(vector<string> &, size_t, size_t, size_t)’:
main.c开发者_StackOverflow中文版pp:56:   instantiated from here
main.cpp:36: error: No match for ‘boost::thread::thread(<unresolved overloaded function type>, vector<string> &, size_t, size_t, size_t)’
main.cpp:41: error: No match for ‘boost::thread::thread(<unresolved overloaded function type>, vector<string> &, size_t, size_t, size_t)’

Here, I've used "left+0" instead of left so that the error is not of the form

main.cpp:41: error: No match for ‘boost::thread::thread(<unresolved overloaded function type>, vector<string> &, size_t, size_t &, size_t)’

How can I remove this ambiguity?


It needs to be quicksortInPlace<T>.

0

精彩评论

暂无评论...
验证码 换一张
取 消