Reputation: 25
I have a threading pool program in c++ that works on my windows machine in visual studio. I'm pretty new to c++ and have never developed it on a linux based system. I'm attempting to build the same program in a docker container using ubuntu and g++. However, I keep getting the following error...
threadpool.h: In member function 'void ThreadPool::map(Func&&, Iterator, Iterator)':
threadpool.h:73:33: error: type/value mismatch at argument 1 in template parameter list for 'template<class T, class> struct ThreadPool::is_iterator'
73 | static_assert(!is_iterator<end>::value, "End argument needs to be an iterator");
| ^
threadpool.h:73:33: note: expected a type, got 'end'
If I'm reading this right, it says that end needs to be a type, this error is generated from the below code....
template <typename Func, typename Iterator>
inline void map(Func&& f, Iterator begin, Iterator end)
{
static_assert(!is_iterator<Iterator>::value, "Begin argument needs to be an iterator");
static_assert(!is_iterator<end>::value, "End argument needs to be an iterator");
for (auto i = begin; i != end; ++i)
{
push(f, *i);
}
}
I think I'm declaring Iterator to be a typename, but it still has a problem. The only other thing I can think of is that I'm not bringing in the correct libraries. My dockerfile looks like this...
# Get the base Ubuntu image from Docker Hub
FROM ubuntu:latest
# Update apps on the base image
RUN apt-get -y update && apt-get install -y
# Install the Clang compiler
RUN apt-get -y install clang
# Install the G++ Compiler
RUN apt-get install -y g++
# Install Ruby
RUN apt-get install -y ruby
# Install Python
RUN apt-get install -y python
# Copy the current folder which contains C++ source code to the Docker image under /usr/src
COPY . /usr/src/threading
# Specify the working directory
WORKDIR /usr/src/threading
# Use G++ to compile the Test.cpp source file
RUN g++ -o threading threading.cpp -lpthread -std=c++17
# Run the output program from the previous step
CMD ["./threading"]
Any help would be appreciated. I can post more code if necessary!
Upvotes: 1
Views: 216
Reputation: 26
If you are using
How to check if an arbitrary type is an iterator?
for your is_iterator methods, you will notice that those methods check if a Type is an Iterator, while end is a function Parameter. So to compile it You can go:
static_assert(is_iterator<Iterator>::value, "Begin argument needs to be an iterator");
static_assert(is_iterator<decltype(end)>::value, "End argument needs to be an iterator");
Be aware that's redundant as both begin and end share the same type.
Upvotes: 1