std::uses_allocator<T, inner_allocator_type>::value==true
場合、私はここにいくつかの単語http://en.cppreference.com/w/cpp/memory/scoped_allocator_adaptor/constructのstd :: scoped_allocator_adaptorとクラス:: allocator_arg_t
を見つける(タイプ Tはアロケータを使用して、例えば、それはコンテナである)
そして
std::is_constructible<T, std::allocator_arg_t, inner_allocator_type, Args...>::value==true
、はその後
を呼び出す場合私もstd::allocator_traits<OUTERMOST>::construct(OUTERMOST(*this), p, std::allocator_arg, inner_allocator(), std::forward<Args>(args)...);
use_arg
を置き換えるためにuse_a
を書く210
だから、私は簡単なテスト
struct use_arg {
template <typename Alloc>
use_arg(std::allocator_arg_t, Alloc &, int i)
{ std::cout << i << " in use_arg()\n"; }
};
namespace std {
template <typename A> struct uses_allocator<use_arg, A>: true_type {};
} // namespace std
void test_scoped()
{
std::scoped_allocator_adaptor<std::allocator<use_arg>> sa;
auto p = sa.allocate(1);
sa.construct(p, 4);
sa.destroy(p);
sa.deallocate(p, 1);
}
を行うが、gccと打ち鳴らすは私にこれらのエラーhttps://gist.github.com/anonymous/3e72754a7615162280fb
を与えます。それは正常に実行することができます。
struct use_a {
template <typename Alloc>
use_a(int i, Alloc &) { std::cout << i << " in use_a()\n"; }
};
これらの動作はどうなりますか?
'std :: is_constructible >> :: value'はどうでしょうか?それはまた「偽」ですが、構築することができます。 –
linux40
@ linux40これはバグのように見えます。たとえば、clangではこのチェックはなく、uses_allocator :: valueだけがチェックされています。 – ForEveR
gccにはチェックが1つしかありません。 – ForEveR