CLion showing error using boost - c++

So I was starting my first project using CLion and the boost library, and following the "getting started" guide from the boost webpage, I have written the following program:
#include <boost/lambda/lambda.hpp>
#include <iostream>
int main()
{
using namespace boost::lambda;
using namespace std;
std::for_each(
istream_iterator<int>(std::cin), istream_iterator<int>(), cout <<(_1 * 3) << " " );
}
Now I have cout <<(_1 * 3) << " "underlined as an error in the IDE saying that the binary operator << is not being applied to the correct types. However the program compiles and runs without errors.
It is not a major issue, but it's a bit annoying and I'm quite curious about the cause of it.

Related

Why does codeblocks ide raise: fatal error: iostream: no such file or directory

when I run this test code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << end1;
return 0;
}
with a more than less than around iostream just can't use it on stackover flow.
I got this code from an old book (2014) it might be outdated. I've never used C++ before how do I fix this.

Visual Studio stating "Microsoft is not a class or namespace name"

I am using Visual Studio 2019 and developing in C++.
I have installed Microsoft Cognitive services by following this walkthrough and my pakcages.config looks correct.
Now when following this tutorial to use cognitive speech, my c++ solution will not build stating "Microsoft is not a class or namespace name"
This shows the error and the sample code and the packages.config file
code and error screenshot
packages.config
I suggest that you could add speechapi_cxx.h in Properties->VC++ Directories->Include Directories.
The path is cognitive-services-speech-sdk-master\quickstart\cpp\windows\from-microphone\packages\Microsoft.CognitiveServices.Speech.1.15.0\build\native\include\cxx_api.
Also, you need to add the code using namespace Microsoft::CognitiveServices::Speech::Audio;.
Here is the complete codeļ¼š
#include <iostream>
#include <speechapi_cxx.h>
using namespace std;
using namespace Microsoft::CognitiveServices::Speech::Audio;
using namespace Microsoft::CognitiveServices::Speech;
auto config = SpeechConfig::FromSubscription("real_sub_id", "region");
int main()
{
std::cout << "Hello World!\n";
auto audioCofig = AudioConfig::FromDefaultMicrophoneInput();
auto recognizer = SpeechRecognizer::FromConfig(config, audioCofig);
cout << "Speak " << endl;
auto result = recognizer->RecognizeOnceAsync().get();
cout << "RECOGNIZED: Text=" << result->Text;
}
I don't know much about the library you are using, but i am sure that you need to #include something before you can actually use the library.

CLion finds a wrong function signature

I constantly have CLion editor showing me parameter type mismatch errors while during build everything is fine. For example, consider the following MWE:
#include <iostream>
#include <boost/container/flat_set.hpp>
using namespace std;
namespace bc = boost::container;
int main() {
bc::flat_set<bc::flat_set<int>> manySets;
bc::flat_set<int> oneSet({1, 2, 3});
manySets.insert(oneSet);
cout << "Hello, World!" << endl;
return 0;
}
Here flat_set is a template from boost library (description could be seen here). Editor shows me an error:
But when I build it (even from CLion), everything is compiled fine.
My system is:
Ubuntu 15.10 64bit
CLion 1.2.4
This looks like a known problem - https://youtrack.jetbrains.com/issue/CPP-6027. We hope to fix it soon.

build does not stop in Visual Studio 2010

I try to build a simple piece of code in Visual Studio, but the building process gets entangled in an infinite loop.
The code is simple:
// test.cpp : Defines the entry point for the console application.
//
#include <iostream.h>
using namespace std;
int main(void)
{
cout << "Hi." << endl;
return 0;
}
Any idea what is going on?
Thanks.
spot several things:
not sure what's in 'stdafx.h'
#include < iostream >
std::cout, std::endl (unless using namespace std; somewhere)
Build works fine for me, though.

C++ Multiple definitions error

I'm getting a bunch of errors for a simple c++ hello world program.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
return 0;
}
All the solutions iv'e seen for this were just confusing and didn't help. Im using the Code Blocks IDE.