Failed to compile program using boost::program_options and lambda expression - by jensa79

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 720670 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/25/2012 12:53:57 AM
Access Restriction Public
Moderator Decision Sent to Engineering Team for consideration

Description

Hi,

compiling the following program fails with the error message:
Error 1 error C2871: 'validators' : a namespace with this name does not exist 
Error 2 error C2871: 'program_options' : a namespace with this name does not exist 

#include <boost/program_options.hpp> 


template<typename T> void f(T t) {} 


void g() 
{ 
   using namespace boost::program_options; 


   // each of the following lines produces the error: 
   // Error 1 error C2871: 'validators' : a namespace with this name does not exist 
   // Error 2 error C2871: 'program_options' : a namespace with this name does not exist 


   f([]() {} ); 
   auto x = []() {}; 
} 

The same source code compiles fine with gcc and I don't see any reason for the error, so I suspect a compiler problem.
Sign in to post a comment.
Posted by Microsoft on 2/1/2012 at 3:55 PM
Hello,

Thank you for reporting this bug. We've made sure that this bug is fixed in the current in-progress release of Visual Studio. Next major release of VS will have the fix.

In the meantime, you workaround the bug by moving up the using namespace statement into global scope:
using namespace boost::program_options;
template<typename T> void f(T t) {}

void g()
{
// using namespace boost::program_options;

f([]() {} );
auto x = []() {};
}

Thanks,
Ulzii Luvsanbat
Windows C++ Team
Posted by MS-Moderator07 [Feedback Moderator] on 1/25/2012 at 7:39 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 1/25/2012 at 1:43 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)