Boost logo

Boost :

Subject: [boost] Template Help
From: john.klein_at_[hidden]
Date: 2014-11-26 12:30:00


All,

I've gotten rusty over the years and decided to create an application for myself to knock some of the rust off.
I've worked with projects that have used boost in the past and I'm wanting to use it as much as possible here.
I'm using VS2013 with the 64bit 1.57.0 boost libraries, so I have access to the newer c++ standard.

Can someone please show me how to get the following to compile?
Please ignore the functionality of the code, this is just something I quickly put together to demo my issue.

SafeList.h
#pragma once
#include <list>
#include <boost/thread/mutex.hpp>

template <typename dataType>
using CallbackType = bool(*)(dataType);

template <typename dataType>
class SafeList
{
public:
   SafeList() :
      list(),
      mutex()
   {
   }

   ~SafeList()
   {
      boost::mutex::scoped_lock scoped_lock(mutex);
   }

   void Add(dataType data)
   {
      boost::mutex::scoped_lock scoped_lock(mutex);
      list.push_back(data);
   }

   void Remove(dataType data)
   {
      boost::mutex::scoped_lock scoped_lock(mutex);
      list.remove(data);
   }

   void IterateList(CallbackType<dataType> callback)
   {
      boost::mutex::scoped_lock scoped_lock(mutex);
      for (int i = 0, bool flag = true; i < list.size() && flag; i++)
      {
         flag = callback(list[0]);
      }
   }

private:
   std::list<dataType> list;
   boost::mutex mutex;
};

FileList.h
#pragma once
#include "SafeList.h"
#include "File.h"
#include <boost/shared_ptr.hpp>

typedef boost::shared_ptr<File> FilePtr;

class FileList
{
public:
   FileList();
   ~FileList();
   void Add(FilePtr);
   void ProcessList();
private:
   bool ProcessItem(FilePtr);
   SafeList<FilePtr> safeList;
};

FileList.c
#include "stdafx.h"
#include "FileList.h"

FileList::FileList() :
safeList()
{
}

FileList::~FileList()
{
}

void FileList::Add(FilePtr filePtr)
{
   safeList.Add(filePtr);
}

void FileList::ProcessList()
{
   safeList.IterateList(this->ProcessItem); <-- This is the bad guy the compiler complains about and not sure how to resolve.
}

bool FileList::ProcessItem(FilePtr)
{
   return true;
}

1>------ Build started: Project: Download, Configuration: Debug x64 ------
1> FileList.cpp
1>FileList.cpp(20): error C3867: 'FileList::ProcessItem': function call missing argument list; use '&FileList::ProcessItem' to create a pointer to member
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thanks,
John Klein PMP(r) CSM(r)
Programs/Engineer Manager
Phone: (319) 378-8455
Cell: (319) 533-1476

[Description: Genova Tech NEW]
www.genovatech.com<http://www.genovatech.com/>

4250 River Center Court NE
Suite A
Cedar Rapids, IA 52402

This message is covered by the Electronic Communication Privacy Act, 18 U.S.C. Sections 2510-2515, and is intended only for the use of the person to whom it is addressed and may contain information that is confidential. It should not be forwarded to anyone else. If you received this message and are not the addressee, you have received this message in error. Please notify the person sending the message and destroy your copy.



image001.jpg

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk