News for hackers. Stuff that matters.
Re:Metaprogramming with Modern C++: The Haskell Metaphor by kazinator on Saturday November 29, 2014 @01:30AM (#8673245)
> Thats all! Simple, isn’t it? Here’s std::decay in the Turbo way:

  template< class T >
  struct decay {
      using U = tml::eval<std::remove_reference<T>>;
      
      using type = tml::eval<
		   tml::conditional<
				    std::is_array<U>,
				    tml::eval<std::remove_extent<U>>*,
				    tml::conditional<
						     std::is_function<U>,
						     std::add_pointer<U>,
						     std::remove_cv<U>
						    >
				   >
			    >;
  };
> I found it much more readable. What do you think?

I think:

1. Programming in XML notation is starting to look good, suddenly.

2.

  (def-compile-time-gizmo decay (x)
    (let ((u (remove-reference x)))
      (cond
        ((is-array u) (remove-extent u))
        ((is-function u) (add-pointer u))
        (t (remove-cv u)))))
3. Why isn't tml::conditional just called tml::if, if it (evidently) only takes three arguments: expr, then, else?
Re:Metaprogramming with Modern C++: The Haskell Metaphor by pjtr on Saturday November 29, 2014 @02:32AM (#8673328)
3: Probably because if is a keyword and can't be used. (And it's based on ''std::conditional'' standardized in C++ 11, but that's begging the question.)
Re:Metaprogramming with Modern C++: The Haskell Metaphor by Manu343726 on Saturday November 29, 2014 @05:17AM (#8673504)
Exactly. if is a C++ keyword. I selected tml::conditional following the Standard std::conditional. The boost::mpl library uses mpl::if_, for example.
Re:Metaprogramming with Modern C++: The Haskell Metaphor by Manu343726 on Saturday November 29, 2014 @05:44AM (#8673526)
"Programming in XML notation is starting to look good, suddenly" I hate the typename ::type pattern. tml::eval helps a lot, but still involves a lot of nested template "calls". To deal with this, I'm working on a continuation system for C++ templates: https://github.com/Manu343726/Flux