Stati c инициализация рекурсивного типа данных - PullRequest
0 голосов
/ 08 мая 2020

У меня есть следующий код

#include <array>
#include <string_view>
#include <utility>

template<typename ... T>
struct node {};

template<typename head_t, typename ... tail_t>
struct node<head_t, tail_t ...>
{
  node(const head_t& head, const tail_t& ... tail)
    : head(head)
    , tail(tail...)
  {}

  head_t head;
  node<tail_t ... > tail;
};

template <typename... T>
node(T... t) -> node<T...>;

, который я могу инициализировать с помощью

template <typename T>
using key = std::pair<std::string_view, T>;

int main()
{
  node n{key<int>{"a", 4}, key<int>{"b", 5}};
  return 0;
}

и скомпилировать с помощью

g++ -Wall -Wextra -Wpedantic -std=gnu++17 -o test -c test.cpp

Мой вопрос: почему mallo c получить вызов в этом сценарии (обнаружен с помощью флага -Wl,--wrap=malloc)?

...