Errors with find_if() & mem_fun1() - visual-studio

I have code that worked well in Visual C++ 6.0. Now I need to get it working in VS 2017. I have some error messages when I compile, and I'm really not sure how to fix it. Here's the code:
class CTagDB : public CObject
{
...
bool SameTag (const CTagDB *TagDB) { return TagDB && *this == *TagDB; }
...
}
class CTagsDB : public CObject
{
...
std::vector<CTagDB*> m_Tags;
...
}
bool CTagsDB::IsDup(const CTagDB *TagDB) const
{
return std::find_if(m_Tags.begin(), m_Tags.end(),
std::bind2nd(std::mem_fun1(CTagDB::SameTag),
TagDB)) != m_Tags.end();
}
For this code I get the following errors:
error C2039: 'mem_fun1': is not a member of 'std' C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include\map(16):
note: see declaration of 'std'
error C3867: 'CTagDB::SameTag': non-standard syntax; use '&' to create a pointer to member
error C3861: 'mem_fun1': identifier not found
error C2672: 'std::find_if': no matching overloaded function found
error C2780: '_InIt std::find_if(_InIt,_InIt,_Pr)': expects 3 arguments - 2 provided
Seeing the methods begin() & end(), I suspect that there is a problem with the way the vectors are being used, because originally the code was written without iterators. But this fragment of code is so clever as to be very difficult to decipher, let alone maintain (by me).
Can anyone help me figure out what is going on here and how to fix it?

Related

'RedisCluster' has no member named 'get_shards_pool'

I am trying to build DeathStarBench (https://github.com/delimitrou/DeathStarBench), however, I am getting the following error:
In file included from /social-network-microservices/src/HomeTimelineService/HomeTimelineService.cpp:15:0:
/social-network-microservices/src/HomeTimelineService/HomeTimelineHandler.h: In member function 'virtual void social_network::HomeTimelineHandler::WriteHomeTimeline(int64_t, int64_t, int64_t, int64_t, const std::vector&, const std::mapstd::__cxx11::basic_string<char, std::__cxx11::basic_string >&)':
/social-network-microservices/src/HomeTimelineService/HomeTimelineHandler.h:129:55: error: 'class sw::redis::RedisCluster' has no member named 'get_shards_pool'
auto *shards_pool = _redis_cluster_client_pool->get_shards_pool();
I don't know anything about Redis. However, I googled the error message and couldn't find anything related to this. Any suggestions on what might be the problem?

Botan build error 'AutoSeeded_RNG' does not name a type

Trying to build the Botan executable, I am getting the following error:
../src/cli/timing_tests.cpp: In static member function 'static Botan::RandomNumberGenerator& Botan_CLI::Timing_Test::timing_test_rng()':
../src/cli/timing_tests.cpp:100:17: error: 'AutoSeeded_RNG' does not name a type
static AutoSeeded_RNG static_timing_test_rng(Botan::Entropy_Sources::global_sources(), 0);
^~~~~~~~~~~~~~
../src/cli/timing_tests.cpp:101:17: error: 'static_timing_test_rng' was not declared in this scope
return static_timing_test_rng;
^~~~~~~~~~~~~~~~~~~~~~
../src/cli/timing_tests.cpp:101:17: note: suggested alternative: 'timing_test_rng'
return static_timing_test_rng;
^~~~~~~~~~~~~~~~~~~~~~
timing_test_rng
make: *** [Makefile:606: build/obj/cli/timing_tests.o] Error 1
this is the C++ code:
static Botan::RandomNumberGenerator& timing_test_rng()
{
#if defined(BOTAN_HAS_SYSTEM_RNG)
return Botan::system_rng();
#elif defined(BOTAN_HAS_AUTO_SEEDING_RNG)
static AutoSeeded_RNG static_timing_test_rng(Botan::Entropy_Sources::global_sources(), 0);
return static_timing_test_rng;
#else
// we could just use SHA-256 in OFB mode for these purposes
throw CLI_Error("Timing tests require a PRNG");
#endif
}
I am using these settings:
configure.py --prefix=$BUILD_DIR --with-external-includedir=$OPENSSL_PREFIX/include --with-external-libdir=$OPENSSL_PREFIX/lib --os=mingw --cpu=i386 --minimized-build --enable- modules=rsa,dsa,ecdsa,ed25519,hmac,hmac_drbg,mode_pad,bigint,filters,block,auto_rng,x509,cbc,dh --with-openssl
(building with mingw32, in Windows 10. Botan version 2.11.0)
I am pretty new on this. Any ideas?
EDIT: Changed to version 2.10.0, since 2.11.0 is not yet official, however the error did now change, to :
undefined reference to 'Botan::CPUID::state()'
Seems like adding entropy source system_rng solves this problem. Just add it to the enable-modules list. Got this from Jack Lloyd, creator of the Botan lib,

Why there is no autocomplete from Intellisens?

Trying a C++ example with VS 2017 and Unreal I saw in the video once the instructor type ->GetF the intellisense appear but with me it does not so why is that ? I am getting also a red line error under the word GetWorld() "pointer to incomplete class type is not allowed" but the code compile fine !!
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();
ActorThatOpen = GetWorld()->GetFirstPlayerController()->GetPawn();
}

C++: C2511: Overloaded member function not found. problems when using 'this'

I have this one object that tries to call a function in another class's function. That function looks like this (Belongs to class 'Player' ):
void play(Game *const currentGame, int x, int y);
When I try to call this function from another object (of the Game class) like this :
player->play(this, x, y)
And during compilation I get these errors:
Error 1 error C2061: syntax error : identifier 'Game' c:\users\shaqed\documents\visual studio 2013\projects\exe3\tictactoe.h 24 1 Exe3
Error 3 error C2511: 'void Player::play(Game *const ,int,int)' : overloaded member function not found in 'Player' c:\users\shaqed\documents\visual studio 2013\projects\exe3\tictactoe.cpp 40 1 Exe3
Error 4 error C2660: 'Player::play' : function does not take 3 arguments c:\users\shaqed\documents\visual studio 2013\projects\exe3\tictactoe.cpp 158 1 Exe3
I came from Java, so maybe I lack some of the core principles about pointers and reference, however I could figure out why there's a type mismatch in here.
Thanks in advance
I have repeated your problem with the same compile errors. I think you have forgotten to add at the end of your method the body. Like:
void play(const Game *currentGame, int x, int y){}

Compiling OpenMCU in Linux (Fedora12)

I am tring to compile OpenMCU in fedora 12. Since the orignal project was compiled in VC++, it has some compatiility issues with gcc.
I am using gcc 4.4.4 and febora 12.
The error shows somehting like this.
In file included from mcu.h:84,
from main.cxx:56:
filemembers.h:123: error: ISO C++ forbids declaration of ‘deque’ with no type
filemembers.h:123: error: typedef name may not be a nested-name-specifier
filemembers.h:123: error: expected ‘;’ before ‘<’ token
filemembers.h:124: error: ISO C++ forbids declaration of ‘FilenameList’ with no type
filemembers.h:124: error: expected ‘,’ or ‘...’ before ‘&’ token
In file included from mcu.h:84,
from main.cxx:56:
filemembers.h:149: error: ‘FilenameList’ does not name a type
make: *** [obj_linux_x86_r/main.o] Error 1
when checked in the source code of that perticular file it was something like this...
class ConferenceFileMember : public ConferenceMember
{
PCLASSINFO(ConferenceFileMember, ConferenceMember);
public:
ConferenceFileMember(Conference * conference, const PFilePath & _fn, PFile::OpenMode mode);
*typedef std::deque<PFilePath> FilenameList; //Line 123..*
ConferenceFileMember(Conference * conference, const FilenameList & _fns, PFile::OpenMode mode);
~ConferenceFileMember();
void Unlisten();
Seems to be a simple syntax issue. Can someone help me in this regards?
Thanx in advance..
Looks like std::deque is not defined. Did you #include <deque>?

Resources