次の方法で共有


list::remove (STL/CLR)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at list::remove (STL/CLR).

Removes an element with a specified value.

Syntax

void remove(value_type val);  

Parameters

val
Value of the element to remove.

Remarks

The member function removes an element in the controlled sequence for which ((System::Object^)``val``)->Equals((System::Object^)x) is true (if any). You use it to erase an arbitrary element with the specified value.

Example

// cliext_list_remove.cpp   
// compile with: /clr   
#include <cliext/list>   
  
int main()   
    {   
    cliext::list<wchar_t> c1;   
    c1.push_back(L'a');   
    c1.push_back(L'b');   
    c1.push_back(L'c');   
  
// display initial contents " a b c"   
    for each (wchar_t elem in c1)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
// fail to remove and redisplay   
    c1.remove(L'A');   
    for each (wchar_t elem in c1)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();  
  
// remove and redisplay   
    c1.remove(L'b');   
    for each (wchar_t elem in c1)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
    return (0);   
    }  
  
a b c  
a b c  
a c  

Requirements

Header: <cliext/list>

Namespace: cliext

See Also

list (STL/CLR)
list::clear (STL/CLR)
list::erase (STL/CLR)
list::remove_if (STL/CLR)