【发布时间】:2015-09-24 10:28:58
【问题描述】:
对于以下示例类,getter 方法的exception safety 保证是什么?
这种 getter 方法是否提供了最低限度的强保证?
按值返回基本类型是否总是提供不抛出保证?
class Foo
{
public:
// TODO: Constructor
// Getter methods
int getA() const { return a; }
std::string getB() const { return b; }
std::vector<int> getC() const { return c; }
Bar getD() const { return d; }
std::vector<Bar> getE() const { return e; }
protected:
int a;
std::string b;
std::vector<int> c;
Bar d;
std::vector<Bar> e;
}
【问题讨论】:
标签: c++ exception exception-safety