Chapter 78. Available printing destinations

#include <x/cups/available.H>

std::vector<x::cups::available> printers=x::cups::available_destinations();

auto iter=std::find(printers.begin(), printers.end(),
                    []
                    (const auto &available_printer)
                    {
                        return available_printer->is_default();
                    });

if (iter != printers.end())
{
    x::cups::available available_destination=*iter;

    std::cout << available_destination->name() << std::endl;
    do_something_with_default_printer(available_destination);
}

x::cups::available_destinations() queries the local network, and returns a vector of available print destinations. Each destination is an x::cups::available object that provides some basic information about the printer.