Project

General

Profile

Actions

Support #4424

open

(boost:: && std::) bind of Wt::WApplication* application_creator fails with too few arguments

Added by Markus Klemm over 8 years ago. Updated over 8 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
08/26/2015
Due date:
% Done:

0%

Estimated time:

Description

This is the problem I asked a few weeks ago on stackoverflow in the Wt section, so for better formatting I recommend reading there:

http://stackoverflow.com/q/31968857/3537677

--- Summary of link content

I want to bind my additional parameters for my Wt::WApplication* MDDB_Service::application_creator(const Wt::WEnvironment& env, int foo); function like in the example. My solution compiles perfectly with gcc/mingw but with MSVC/Visual Studio 2013 Express, it fails with the error: "Error 94 error C2198: 'Wt::WApplication *(__cdecl *)(const Wt::WEnvironment &,int)' : too few arguments for call ...include\boost\function\function_template.h"

I used Wt::WRun(argc, argv,boost::bind(MDDB_Service::application_creator, _1, 5)); and also Wt::WRun(argc, argv,std::bind(MDDB_Service::application_creator, std::placeholders::_1, 5));.

The audience at stackoverflow supposes that this bug may be related to the fact that the default constructor of Wt::WEnvironment is not public.

Wt version : 3.3.4.

Actions #1

Updated by Benoit Daccache over 8 years ago

  • Tracker changed from Bug to Support
  • Status changed from New to Feedback

Hey Markus,

If application_creator is not a static method your bind should take the instance of the class:

eg.

Wt::WRun(argc, argv,std::bind(&MDDB_Service::application_creator,mddb_instance_pointer, std::placeholders::_1, 5));

Otherwise your bind is maybe missing an '&' before the MDDB_SERVICE:

Wt::WRun(argc, argv,std::bind(&MDDB_Service::application_creator,mddb_instance_pointer, std::placeholders::_1, 5));

The instance to WEnvironment will be passed by WRun to the bound function/method, so the visibility of the constructor is not the problem here.

Exemple of working code:

@

WApplication *createApplication(const WEnvironment& env, int i)

{

return new Test(env);

}

int main(int argc, char **argv)

{

return WRun(argc, argv, std::bind(&createApplication, std::placeholders::_1, 1));

}

@

Benoit

Actions #2

Updated by Markus Klemm over 8 years ago

Benoit Daccache wrote:

If application_creator is not a static method your bind should take the instance of the class:

No MDDB_Service is just a namespace, it wasn't a member function /method. And the &operator didn't make a difference.

Anyway:

I was able to reproduce it with your code

@

Wt::WApplication *createApplication(const Wt::WEnvironment& env, int i) {

return new Wt::WApplication(env);

}

int main(int argc, char argv)

{

Wt::WRun(argc, argv,std::bind(&createApplication, std::placeholders::_1, 1));

}

@

Full file and boost snippet error refers to: https://gist.github.com/Superlokkus/fac974528a3831adf165

Error: Error 94 error C2198: 'Wt::WApplication *(__cdecl *)(const Wt::WEnvironment &,int)' : too few arguments for call c:\users\klm\downloads\wt-3.3.4-msvs2013-windows-x86-sdk\include\boost\function\function_template.hpp 95 1 MDDB_Web

BTW: I use your prebuilt binary (with the included boost library).

Actions #3

Updated by Wim Dumon over 8 years ago

Hello,

Your example compiles on my Windows installation on msvs 2013. Granted, I didn't try with our prebuild binaries, but my development setup your code works. It may have been a problem in boost that's solved in the meantime?

BR,

Wim.

Actions #4

Updated by Markus Klemm over 8 years ago

Wim Dumon wrote:

It may have been a problem in boost that's solved in the meantime?

I guess, I'm only using this boost version and msvs 2013 at all, because building Wt is a pain in **, because of the build system of the dependencies.

In the other hand I could be less a official problem of boost, but of msvs 2013, caused by it's limited C++11 support.

Could anyone help me out with a Wt build for MSVS 2015 x64 please, with the full pdf and raster support? I suppose for the sake of compatibility the built packages should be updated anyway.

Actions #5

Updated by Wim Dumon over 8 years ago

Next release will most likely have a msvc2015 build too. However I already noticed not all dependencies compile well with msvs 2015...

Wim.

Actions

Also available in: Atom PDF