/**
 * 最小复现代码
 * Qt Creator 9.0.0
 * Based on Qt 6.4.1 (Clang 13.0 (Apple), arm64)
 */
#include <iostream>
#include <algorithm>
#include <vector>
class Contact {
public:
    Contact(std::string name) { this->name = name; }
    friend bool customSort(const Contact& lhs, const Contact& rhs) { return lhs.name < rhs.name; }
private:
    std::string name;
};
class Book {
public:
    void sortBookByName() {
        /**
         * @bug
         * Semantic Issue
         * Use of undeclared identifier 'customSort'
         * [Source: clangd for friendTest<项目的名字>]
         * 别人在 Windows Qt 上也测试过,提示错误相同
         */
        std::sort(this->addressBook.begin(), this->addressBook.end(), customSort);
        
        // 这个就是正常的
        std::sort(this->addressBook.begin(), this->addressBook.end(), [](const Contact& lhs, const Contact& rhs) {
            return customSort(lhs, rhs);
        });
    }
private:
    std::vector<Contact> addressBook;
};