我想创建template< typename F > using T = boost::variant< F, F const >;
类型以将只读和读写可访问值存储到同一个std::vector< T >
. 但是我遇到了以下编程问题:
#include <iostream>
#include <cstdlib>
#include <boost/variant.hpp>
int main()
{
using F = double;
using CV = boost::variant< F const, F >;
F const c = 0.0;
CV C(c);
F v = 0.0;
CV V(v);
std::cout << C.which() << ' ' << V.which() << std::endl;
return EXIT_SUCCESS;
}
输出:1 1
。如何存储const
type 值的版本F
?