对于静态成员初始化,我使用嵌套的帮助器结构,它适用于非模板化的类.但是,如果封闭类由模板参数化,则如果未在主代码中访问辅助对象,则不会实例化嵌套初始化类.为了说明,一个简化的例子(在我的例子中,我需要初始化一个向量).
#include <string>
#include <iostream>
struct A
{
struct InitHelper
{
InitHelper()
{
A::mA = "Hello, I'm A.";
}
};
static std::string mA;
static InitHelper mInit;
static const std::string& getA(){ return mA; }
};
std::string A::mA;
A::InitHelper A::mInit;
template<class T>
struct B
{
struct InitHelper
{
InitHelper()
{
B<T>::mB = "Hello, I'm B."; // [3]
}
};
static std::string mB;
static InitHelper mInit;
static const std::string& getB() { return mB; }
static InitHelper& getHelper(){ return mInit; }
};
template<class T> …
Run Code Online (Sandbox Code Playgroud) 在阅读getfacl
/ setfacl
我的手册页后,我找不到一个明显/健壮/优雅的方法来检查是否为(ba)sh中的给定路径启用了acl.
有什么建议?