XIEITE_ARROW(), XIEITE_ARROW_CTOR()

Defined in header <xieite/arrow.hpp>
(header-only: <xieite/pp/arrow.hpp>)


Deduplicates the repetition required for defining the body, return type, and noexcept of a single-statement template function.
(i.e. eliminates annoying typing when defining forwarding function templates.)


Definitions

#0
#define XIEITE_ARROW(...) \
	noexcept(noexcept(__VA_ARGS__)) \
	-> decltype(__VA_ARGS__) \
	{ return __VA_ARGS__; }
The explicit trailing return type is helpful for overload resolution.

#1
#define XIEITE_ARROW_CTOR(...) \
		noexcept(noexcept(__VA_ARGS__)) \
		: __VA_ARGS__ {}
Intended for delegating constructors: struct D : B { D(int x) XIEITE_ARROW_CTOR(B(x)) {} };


Example

#include <xieite/arrow.hpp>
import xieite;

auto add(auto a, auto b) XIEITE_ARROW(a + b)

struct S {
	void operator+(S) {} // not marked `noexcept`
};

int main() {
	xieite::dump(noexcept(add(1, 2)));
	xieite::dump(noexcept(add(S(), S())));
}
Output:
true
false