These are chat archives for boostorg/hana

17th
Mar 2017
Jason Rice
@ricejasonf
Mar 17 2017 21:38

@ldionne I'm confused about the relationship between hana::to and hana::is_convertible or there is possibly a bug here:

#include <boost/hana.hpp>
#include <iostream>

namespace hana = boost::hana;

constexpr hana::string<'f', 'o', 'o'> foo_s{};

int main() {
  static_assert(
    hana::not_(hana::is_convertible<decltype(foo_s), char const*>{})
  , "Key must NOT be convertible to string. ??"
  );

  std::cout << hana::to<char const*>(foo_s) << '\n';
}

Here hana::to works, but hana::is_convertible returns a false_type

Louis Dionne
@ldionne
Mar 17 2017 21:45

The documentation says:

Specifically, is_convertible<From, To> is whether calling to<To> with an object of data type From would not trigger a static assertion.

From should be the data type of the object, not its C++ type. So is_convertible<string_tag, char const*> should work.

Jason Rice
@ricejasonf
Mar 17 2017 21:45
aha thank you!
Louis Dionne
@ldionne
Mar 17 2017 22:18
np. I agree it’s confusing, but it’s consistent with the rest of the library that has this notion of data type. It’s all very consistent, but not always the most user friendly.