Home Dashboard Directory Help
Search

std algorithm functions do not compile in certain case by cubee_q


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 669603
Opened: 5/20/2011 6:30:39 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

When using std algorithm functions inside a lambda, inside an initializer list, the code only compiles when writing a "using namespace std". Fully qualifying the name with "std::" or "::std::" results in an "error C2039: 'copy_if' : is not a member of 'std'"

Look at the code below to get an idea :

#include "stdafx.h"
#include "assert.h"
#include <vector>
#include <set>
#include <algorithm>
#include <iterator>
#include <utility>


class CMyClass
{
public:
    CMyClass( const std::vector< int > & ac_Values )
    : mc_Values( [ & ac_Values ]() -> std::vector< int >
    {
     std::vector< int > lv_Values ;

        // DOES NOT COMPILE
     std::copy_if( ac_Values.begin(), ac_Values.end(), std::back_inserter( lv_Values ), []( const int ) { return true ; } ) ;

        // DOES COMPILE
     using namespace std ;
     copy_if( ac_Values.begin(), ac_Values.end(), back_inserter( lv_Values ), []( const int ) { return true ; } ) ;
    
     return lv_Values ;    
    } () )
    {
    }

private:
    const std::vector< int > mc_Values ;
};

int _tmain(int argc, _TCHAR* argv[])
{
CMyClass a( std::vector< int >( 10, 1 ) ) ;
    return 0;
}
Details
Sign in to post a comment.
Posted by Microsoft on 6/11/2011 at 7:24 PM
Hi:
    A fix for this issue has been checked into the compiler sources.
    The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Compiler Team
Posted by MS-Moderator07 [Feedback Moderator] on 5/22/2011 at 9:31 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-Moderator07 on 5/22/2011 at 7:10 PM
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/
Sign in to post a workaround.