- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 
                        foreach ($files as $n => $f) {
    $new_content = $common.$namespace_begin.$f.$namespace_end;
    $std_methods = array();
    preg_match_all('/std::[a-z_0-9]*/', $new_content, $std_methods);
    $std_methods = array_unique($std_methods[0]);
    $needed_std_headers = array();
    $type_headers = array(
        'std::move' => '',
        'std::vector' => '',
        'std::string' => '',
// [...]
        'std::unordered_set' => 'unordered_set');
    foreach ($type_headers as $type => $header) {
        if (in_array($type, $std_methods)) {
            $std_methods = array_diff($std_methods, array($type));
            if ($header && !in_array($header, $needed_std_headers)) {
                $needed_std_headers[] = $header;
            }
        }
    }
    if (!$std_methods) { // know all needed std headers
        $new_content = preg_replace_callback(
            '/#include <([a-z_]*)>/',
            function ($matches) use ($needed_std_headers) {
                if (in_array($matches[1], $needed_std_headers)) {
                    return $matches[0];
                }
                return '';
            },
            $new_content
        );
    }
                                 
        
Закрадываются нехорошие подозрения.
Послание очень длинное.
Читать полностью: ==>
https://www.realworldtech.com/forum/?threadid=189711&curpostid=189752