Guest User

Untitled

a guest
Dec 11th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <tuple>
  2. #include <type_traits>
  3.  
  4. struct Ag{int i;int j;};
  5. using T = std::tuple<int,int>;
  6. using Ar = int[2];
  7.  
  8. const Ag ag {};
  9. const T t {};
  10. const Ar ar {};
  11.  
  12. void bind_ag(){
  13. auto [i,j] = ag;
  14. static_assert(std::is_same_v<decltype((i)),int&>);
  15. }
  16. void bind_t(){
  17. auto [i,j] = t;
  18. static_assert(std::is_same_v<decltype((i)),int&>);
  19. }
  20. void bind_ar(){
  21. auto [i,j] = ar;
  22. static_assert(std::is_same_v<decltype((i)),int&>); //For GCC
  23. static_assert(std::is_same_v<decltype((i)),const int&>); //For Clang (and standard?)
  24. }
Add Comment
Please, Sign In to add comment