Boost logo

Boost Users :

Subject: [Boost-users] boost::thread object initialization. cannot understand.
From: rabbitko_at_[hidden]
Date: 2010-01-17 08:02:34


hallo Group Members

compilation of following simple program leads to an error:

p1.cpp: In function "int main(int, char**)":
p1.cpp:18: error: request for member "join" in "f", which is of non-class type "boost::thread(F (*)())"

#include <boost/thread.hpp>
#include <iostream>

struct F
{
  void operator()()
  {
    while (true) {
      std::cout << "hallo" << std::endl;
    }
  }
};

int main(int argc, char *argv[])
{
  // boost::thread f = boost::thread(F()); // But with this line
                                           // instead, everything
                                           // is ok!!
  boost::thread f(F());
  f.join();
  return 0 ;
}

I am running fc12 with:

prompt$ g++ --version
g++ (GCC) 4.4.2 20091222 (Red Hat 4.4.2-20)
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

prompt$ rpm -qi boost
Name : boost Relocations: (not relocatable)
Version : 1.39.0 Vendor: Fedora Project
Release : 8.fc12 Build Date: czw, 15 paź 2009, 15:15:15
Install Date: sob, 16 sty 2010, 13:38:26 Build Host: x86-3.fedora.phx.redhat.com
Group : System Environment/Libraries Source RPM: boost-1.39.0-8.fc12.src.rpm
Size : 0 License: Boost
Signature : RSA/8, czw, 22 paź 2009, 10:57:44, Key ID 9d1cc34857bbccba
Packager : Fedora Project
URL : http://www.boost.org/
Summary : The Boost C++ Libraries
Description :
Boost provides free peer-reviewed portable C++ source libraries. The
emphasis is on libraries which work well with the C++ Standard
Library, in the hopes of establishing "existing practice" for
extensions and providing reference implementations so that the Boost
libraries are suitable for eventual standardization. (Some of the
libraries have already been proposed for inclusion in the C++
Standards Committee's upcoming C++ Standard Library Technical Report.)

have you got any explanation for this?
Maybe I should learn C++ better?

best regards,
Michal


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net