GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::ignore(3) C++ Standard Libary std::ignore(3)

std::ignore - std::ignore


Defined in header <tuple>
const /*unspecified*/ ignore; (since C++11)
(until C++17)
inline constexpr /*unspecified*/ ignore; (since C++17)


An object of unspecified type such that any value can be assigned to it with no
effect. Intended for use with std::tie when unpacking a std::tuple, as a placeholder
for the arguments that are not used.


It can also be used to avoid warnings from unused return values of [[nodiscard]]
functions.


namespace detail {
struct ignore_t {
template <typename T>
constexpr // required since C++14
void operator=(T&&) const noexcept {}
};
}
inline constexpr detail::ignore_t ignore; // 'const' only until C++17


1. Demonstrates the use of std::ignore together with a [[nodiscard]] function.
2. Unpacks a std::pair<iterator, bool> returned by set.insert(), but only saves the
boolean.

// Run this code


#include <iostream>
#include <string>
#include <set>
#include <tuple>


[[nodiscard]] int dontIgnoreMe()
{
return 42;
}


int main()
{
std::ignore = dontIgnoreMe();


std::set<std::string> set_of_str;
bool inserted = false;
std::tie(std::ignore, inserted) = set_of_str.insert("Test");
if (inserted) {
std::cout << "Value was inserted successfully\n";
}
}


Value was inserted successfully


tie creates a tuple of lvalue references or unpacks a tuple into individual
(C++11) objects
(function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.