2010-02-26 61 views
2

我試着轉發declare concurrent_bounded_queue;如何轉發聲明以下模板類

class MyClass { 
    namespace tbb { 
     template<typename T> class cache_aligned_allocator; 
     template<class T, class A = cache_aligned_allocator> class concurrent_bounded_queue; 
    }; 

    // I wish to maintain this syntax. 
    tbb::concurrent_bounded_queue<std::string>& concurrentBoundedQueue; 
} 

我得到以下錯誤:

error C3203: 'cache_aligned_allocator' : unspecialized class template can't be used as a template argument for template parameter 'A', expected a real type 
error C2955: 'tbb::cache_aligned_allocator' : use of class template requires template argument list c:\projects\vitroxreport\src\Executor.h(21) : see declaration of 'tbb::cache_aligned_allocator' 

可我知道我該怎麼避免?

謝謝。

回答

5

Allocator是一個模板,但隊列的第二個參數是具體類。試試這個:

class MyClass { 
    namespace tbb { 
     template<typename T> class cache_aligned_allocator; 
     template<class T, class A = cache_aligned_allocator<T> > 
      class concurrent_bounded_queue; 
    }; 

    tbb::concurrent_bounded_queue<std::string>& concurrentBoundedQueue; 
}; 
+0

工程只是迷人的。謝謝。 – 2010-02-26 03:39:24