kokkos / array_ref

Polymorphic multidimensional array view
36 stars 9 forks source link

Notes on proposal #30

Closed mbianco closed 7 years ago

mbianco commented 8 years ago

notes for the r3 branch

#include <type_traits>                                                                                                                                                                                      

template <typename T...>                                                                                                                                                                                    
using void_t = void;                                                                                                                                                                                        

struct my_layout {                                                                                                                                                                                          
    template <typename DType, DType...>                                                                                                                                                                     
    struct mapping {                                                                                                                                                                                        
        using is_mapping = std::true_type;                                                                                                                                                                  
    };                                                                                                                                                                                                      

};                                                                                                                                                                                                          

template <typename T, typename Dummy=void>                                                                                                                                                                  
struct is_layout : std::false_type {};                                                                                                                                                                      

template <typename T>                                                                                                                                                                                       
struct is_layout<T, void_t<typename T::template mapping<int> > > : std::true_type {};                                                                                                                       

int main() {                                                                                                                                                                                                
    static_assert(is_layout<my_layout>::value, "");                                                                                                                                                         
    static_assert(!is_layout<int>::value, "");                                                                                                                                                              

}                                                                                                                                                                                                           
hcedwar commented 7 years ago

done in current version