I have a program which will successfully compile on my mac but when I try on my linux desktop it cannot. Instead, I get the following error:
plot.cpp:12:63: error: converting to ‘std::tuple<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >’
from initializer list would use explicit constructor
‘constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...)
[with _UElements = {const char (&)[4], const char (&)[6], const char (&)[6]};
<template-parameter-2-2> = void; _Elements = {std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >}]’
like 12 of plot.cpp
looks like this:
vector<tuple <string, string, string> >{
{"yes", "Agree", "Empty"}, {"no", "Disagree", "Empty"}},
This vector is initialised in header.h
, here:
class Menu
{
std::string _name, _situation, _excuse;
std::vector<std::tuple <std::string, std::string, std::string>> _choices;
std::vector<std::string> _items;
public:
Menu(const std::string &name,
const std::string &situation,
const std::string &excuse,
const std::vector<std::tuple <std::string, std::string, std::string>> &choices = std::vector<std::tuple <std::string,std::string, std::string> >{},
const std::vector<std::string> &items = std::vector<std::string>{});
virtual ~Menu ();
const bool operator==(const std::string &name);
const std::string& Explain_Choice();
const void Enter_String();
std::string choice;
std::string ItemChoice;
const void Present_Choice() ;
const void No_Choice();
};
I have looked around a bit and I suspect the error is coming from the line in header.h
where I say &choices =
. However, my attempts to initialise this differently have not worked.
I have 2 questions. Firstly, why can this code compile on my mac but not on linux, is one of the compilers somehow ''wrong''? And then secondly, is there any suggestions on how I can change my code to allow it to compile on the Linux machine.