使用boost::hana::is_nothing判断变量是否为空
在C++中,判断一个变量是否为空是经常性的需求。在boost::hana库中,提供了一个非常便捷的工具——is_nothing,可以用于检查一个变量是否是同于std::optional的空值表示。
is_nothing的定义如下:
template <typename T>
constexpr bool is_nothing(T const& x);
我们来看一段示例代码,通过is_nothing判断变量是否为空:
#include <boost/hana.hpp>
int main() {
auto