Skip to content

Instantly share code, notes, and snippets.

@ricejasonf
Created December 8, 2015 19:40
Show Gist options
  • Save ricejasonf/44bc8632b13c2e03d4c4 to your computer and use it in GitHub Desktop.
Save ricejasonf/44bc8632b13c2e03d4c4 to your computer and use it in GitHub Desktop.
Class Template Member Class Template Definition
#include<boost/hana.hpp>
#include<iostream>
namespace hana = boost::hana;
template<typename T>
class A
{
static constexpr const char* t = hana::to<const char*>(T{});
template<typename>
class B;
public:
template<typename U>
void print()
{
B<U>().print();
}
};
template<typename T>
template<typename U>
class A<T>::B
{
static constexpr const char* u = hana::to<const char*>(U{});
public:
void print()
{
std::cout << t << " " << u;
std::cout << "\n";
}
};
int main()
{
constexpr auto hello = hana::string_c<'h', 'e', 'l', 'l', 'o'>;
constexpr auto world = hana::string_c<'w', 'o', 'r', 'l', 'd'>;
A<decltype(hello)>().print<decltype(world)>();
}
@ricejasonf
Copy link
Author

I guess I could have done .print(world)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment