SHARE
TWEET

Untitled

a guest Jun 19th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template<class T>
  2. class C
  3. {
  4.     void common() { ... }
  5.     void f2 = delete;
  6. };
  7.  
  8. template<>
  9. class C<int>
  10. {
  11.     void common() { ... }
  12.     void f1() { ... }
  13. };
  14.      
  15. template<class T>
  16. class C
  17. {
  18.     void common() { ... }
  19.  
  20.     static_if(std::is_same<T, int>::value)
  21.     {
  22.         void f1( ) { ... }
  23.     }
  24.     else
  25.     {
  26.         void f2( ) = delete;
  27.     }
  28. }
  29.      
  30. struct S {};
  31.  
  32. template<typename T>
  33. struct T
  34.   static_if(is_same<T,int>::value) { : S }  // ?
  35. { };
  36.  
  37. template<typename T>
  38. struct T {};
  39.  
  40. template<>
  41. struct T<int> : S {};
  42.      
  43. template <typename To, typename From> struct ShapeCaster
  44. {
  45.     static To & cast(From & x) { return dynamic_cast<To&>(x); }
  46. };
  47.  
  48. template <> struct ShapeCaster<Triangle, Shape>
  49. {
  50.     static Triangle & cast(Shape & x) { return static_cast<Triangle&>(x); }
  51. };
  52.  
  53. template <typename To, typename From> To & shape_cast(From & x)
  54. {
  55.     return ShapeCaster<To, From>::cast(x);
  56. }
  57.      
  58. To & y = shape_cast<To>::cast(x);
  59.      
  60. template<typename, typename>
  61. struct is_same{
  62.     static constexpr bool value = false;;
  63. };
  64.  template<typename T>
  65. struct is_same<T, T>{
  66.     static constexpr bool value = true;;
  67. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top