Jump to content

Question about new std functions and lambdas


Recommended Posts

Since I haven't got much experience (yet) with C++, dealing with more modern source structures can be really challenging for me, especially in Linux enviroments, where virtual help like Visual Studio and Intellisence are not available. It's been 2 months since I started discovering C++17 and with the help of the community (that's you guys) I learned a lot! One of the most challenging parts were converting an old-written source into a C++17 compilable project and some of the most struggling moments I had was converting the old function

FuncQuery(std::bind1st(std::mem_fun(code...), this), "QUERY FOR DATABASE");

into something acceptable towards the compiler. I ended up with the new bind from the std library:

FuncQuery(std::bind(std::mem_fn(code), this, std::placeholders::_1), "QUERY FOR DATABASE");

and lambda functions:

FuncQuery([this](auto&& data) { return MyClass::MyVoid(data); }, "QUERY FOR DATABASE");

Those conversions took place in a few files of the game source, but most of them were needed in guild.cpp. So my question is this: Is there something wrong with this conversion? Is there a more stable way for the specific game? And most important: Could this conversion be the reason for core/query/other errors or bugs?

Let me know what you think!

Best regards

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Acum 18 ore, Mind Rapist a spus:

Since I haven't got much experience (yet) with C++, dealing with more modern source structures can be really challenging for me, especially in Linux enviroments, where virtual help like Visual Studio and Intellisence are not available. It's been 2 months since I started discovering C++17 and with the help of the community (that's you guys) I learned a lot! One of the most challenging parts were converting an old-written source into a C++17 compilable project and some of the most struggling moments I had was converting the old function


FuncQuery(std::bind1st(std::mem_fun(code...), this), "QUERY FOR DATABASE");

into something acceptable towards the compiler. I ended up with the new bind from the std library:


FuncQuery(std::bind(std::mem_fn(code), this, std::placeholders::_1), "QUERY FOR DATABASE");

and lambda functions:


FuncQuery([this](auto&& data) { return MyClass::MyVoid(data); }, "QUERY FOR DATABASE");

Those conversions took place in a few files of the game source, but most of them were needed in guild.cpp. So my question is this: Is there something wrong with this conversion? Is there a more stable way for the specific game? And most important: Could this conversion be the reason for core/query/other errors or bugs?

Let me know what you think!

Best regards

Try to donate exp intro guild after those conversions ?

Link to comment
Share on other sites

hello, new member here :) i just started a new project and i saw your post. happens to be using same files as u so when i saw it i had to check it out. turns out i got that guild problem as well. idk if this will help but i saw this a lil while ago and i tried this part:

[this](auto&& arg) -> decltype(LoadGuildData(std::forward<decltype(arg)>(arg))) {
    return LoadGuildData(std::forward<decltype(arg)>(arg));
}

what i got was a compiling error and since im no expert im sharing here, if u figure it out may wanna give the solution. compiler says:

Compile release/guild.o
Assertion failed: (CurLSI && "While computing 'this' capture-type for a generic " "lambda, we must have a corresponding LambdaScopeInfo"), function adjustCVQualifiersForCXXThisWithinLambda, file /usr/ports/devel/llvm-devel/work/llvm-a73d657b58931f82df97d1772f2c10d94ac7dc8b/tools/clang/lib/Sema/SemaExprCXX.cpp, line 1018.
Stack dump:
0.      Program arguments: /usr/local/llvm-devel/bin/clang-8 -cc1 -triple i386-portbld-freebsd12.0 -emit-obj -disable-free -main-file-name guild.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fno-trapping-math -ffp-contract=fast -ffast-math -ffinite-math-only -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu i486 -target-feature +sse2 -target-feature +ssse3 -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /root/src/vanilla_source/vanilla/game/src/release/guild.gcno -resource-dir /usr/local/llvm-devel/lib/clang/8.0.0 -D _THREAD_SAFE -D __MARIADB__ -D CRYPTOPP_DISABLE_ASM -D __MARIADB__ -D NDEBUG -I /usr/local/include/mariadb -I /usr/include -I ../../../Internal/liblua/include -I ../../../Internal -I /usr/local/include -D __SVN_VERSION__="71480" -internal-isystem /usr/include/c++/v1 -Ofast -Wall -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /root/src/vanilla_source/vanilla/game/src -ferror-limit 19 -fmessage-length 80 -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o release/guild.o -x c++ guild.cpp -faddrsig
1.      <eof> parser at end of file
2.      ./db.h:140:42: instantiating function definition 'DBManager::FuncQuery<(lambda at guild.cpp:632:34)>'
3.      ./any_function.inc:37:15: instantiating function definition '_boost_func_of_SQLMsg::any::operator=<(lambda at guild.cpp:632:34)>'
4.      ./any_function.inc:13:9: instantiating function definition '_boost_func_of_SQLMsg::any::any<(lambda at guild.cpp:632:34)>'
5.      ./any_function.inc:84:13: instantiating function definition '_boost_func_of_SQLMsg::any::holder<(lambda at guild.cpp:632:34)>::holder'
6.      ./any_function.inc:96:19: instantiating function definition '_boost_func_of_SQLMsg::any::holder<(lambda at guild.cpp:632:34)>::operator()'
libunwind: EHHeaderParser::decodeTableEntry: bad fde: CIE ID is not zero
clang-8: error: unable to execute command: Abort trap (core dumped)
clang-8: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 8.0.0
Target: i386-portbld-freebsd12.0
Thread model: posix
InstalledDir: /usr/local/llvm-devel/bin
clang-8: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-8: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-8: note: diagnostic msg: /tmp/guild-171392.cpp
clang-8: note: diagnostic msg: /tmp/guild-171392.sh
clang-8: note: diagnostic msg:

********************
gmake: *** [Makefile:83: release/guild.o] Error 254

thanks for your time, feels great to be here!

morons-morons-everywhere-x04tm0.jpg.c04419129118e58957deb2b5ff36732c.jpg

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.