I'm currently working on implementing a module, which consist of three functions including Init(), Process() and Release(). And I'd like to find a way to throw compile error if using std::vector::push_back in Process() and Release() functions. Is there any possible way? Thank all!
class AModule {
private:
std::vector<std::int32_t> vector_list;
public:
bool Init() override {
vector_list.push_back(10); // Allow to use push_back function only in Init state
}
void Process() override {
vector_list.push_back(10); // Should throw compile error here
}
void Release() override {
vector_list.push_back(10); // Should throw compile error here
}
};
I have try using static_assert by wrapping the vector class, but it doesnt work properly.
Aucun commentaire:
Enregistrer un commentaire