请考虑以下代码:
template<class basic_ios_type>
class basic_ios_adaptor;
template<template<typename, class> class basic_ios_type, typename char_type, class traits_type>
class basic_ios_adaptor<basic_ios_type<char_type, traits_type>>
: public basic_ios_type<char_type, traits_type>
{
public:
typedef basic_ios_type<char_type, traits_type> base_type;
basic_ios_adaptor(base_type const& other)
: base_type(other)
{
}
};
唯一可用的构造函数是复制构造函数,它接受对基类型的 const 引用。示例用法:
std::ofstream x(std::ofstream("")); // ok
basic_ios_adaptor<std::ofstream> y(std::ofstream("")); // error
视觉 C++:
'std::basic_ios<_Elem,_Traits>::basic_ios' : 无法访问在类 'std::basic_ios<_Elem,_Traits>' 中声明的私有成员
英特尔:
没有构造函数“std::basic_ofstream<_Elem, _Traits>::basic_ofstream [with _Elem=char, _Traits=std::char_traits]”的实例与参数列表匹配
有人可以向我解释为什么这不起作用吗?