Сейчас я понятия не имею, в чем проблема, но я не могу пересматривать и устанавливать значения переменных-членов объектов в векторах этого одноэлементного кортежа (то есть глоток!). По сути, я думаю, что у меня проблемы с синтаксисом, и это связано с отсутствием у меня опыта. Я искал кого-то, кто делал это, но не смог понять, что может происходить.
Суть проблемы заключается в size_t addDevice(); ниже :
Код: Выделить всё
#include
#include
#include
#define TOTAL 100
typedef std::tuple<
std::vector,
std::vector,
std::vector
> SingletonTuple;
class Device
{
public:
Device() { activeStatus = false; };
private:
bool activeStatus;
};
class Controller
{
public:
Controller() { };
size_t addDevice();
class Singleton
{
public:
static Singleton& Instance()
{
static Singleton singleton(TOTAL);
return singleton;
}
private:
friend class Controller;
size_t numDevices;
SingletoneTuple singletonTuple;
Singleton(size_t total);
};
};
Controller::Singleton::Singleton(size_t total)
{
numDevices = total;
Singleton::singleton = std::make_tuple(std::vector(total), std::vector(total), std::vector(total));
}
size_t Controller::addDevice()
{
index = computeIndex(); //defined elsewhere but assume it returns an index
std::get(singleton)[index].activeStatus = true;
std::get(singleton)[index].activeStatus = true;
std::get(singleton)[index].activeStatus = true;
return index;
}
Код: Выделить всё
std::get(singleton)[index].activeStatus = true;
std::get(singleton)[index].activeStatus = true;
std::get(singleton)[index].activeStatus = true;
Я искал решения, но, похоже, никто не пробует этот конкретный подход.
Подробнее здесь: https://stackoverflow.com/questions/787 ... ith-stdget