Created
August 23, 2017 16:11
-
-
Save Zikoel/599b2962311f9562bd1206e9de9e65c5 to your computer and use it in GitHub Desktop.
A way for retrieve type from complex object inside a tuple.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <tuple> | |
#include <unordered_map> | |
template<typename ...TKeyTypes> | |
struct A { | |
std::tuple<std::unordered_map<TKeyTypes, size_t>...> tupled_maps; | |
}; | |
int main() | |
{ | |
A<int, double> a; | |
using mapType = std::tuple_element<0, decltype(a.tupled_maps)>::type; | |
using mapKeyType = mapType::key_type; | |
static_assert(std::is_same<mapType, std::unordered_map<int, size_t>>::value, "!"); | |
static_assert(std::is_same<mapKeyType, int>::value, "!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment