mirror of
https://github.com/mbierlee/poodinis.git
synced 2024-11-15 04:04:01 +01:00
Add backwards compatiblity for isFunction
This commit is contained in:
parent
925c3f4119
commit
cc0ea0d9e4
|
@ -21,6 +21,7 @@ import poodinis.container;
|
||||||
import poodinis.registration;
|
import poodinis.registration;
|
||||||
import poodinis.factory;
|
import poodinis.factory;
|
||||||
import poodinis.valueinjection;
|
import poodinis.valueinjection;
|
||||||
|
import poodinis.polyfill;
|
||||||
|
|
||||||
import std.exception;
|
import std.exception;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import poodinis.autowire;
|
||||||
import poodinis.context;
|
import poodinis.context;
|
||||||
import poodinis.factory;
|
import poodinis.factory;
|
||||||
import poodinis.valueinjection;
|
import poodinis.valueinjection;
|
||||||
|
import poodinis.polyfill;
|
||||||
|
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.algorithm;
|
import std.algorithm;
|
||||||
|
|
|
@ -4,20 +4,29 @@
|
||||||
*
|
*
|
||||||
* Should not implement functionalitiy which is gone from the latest Phobos.
|
* Should not implement functionalitiy which is gone from the latest Phobos.
|
||||||
*
|
*
|
||||||
* Implementations copied/re-implemented from std.exception
|
* Implementations copied/re-implemented from std.exception and std.traits;
|
||||||
*
|
*
|
||||||
* The baseline compatibility is D/Phobos 2.068.2
|
* The baseline compatibility is D/Phobos 2.068.2
|
||||||
*
|
*
|
||||||
* Authors: $(HTTP erdani.org, Andrei Alexandrescu),
|
* Authors: $(HTTP erdani.org, Andrei Alexandrescu),
|
||||||
* Jonathan M Davis,
|
* Jonathan M Davis,
|
||||||
* Mike Bierlee (m.bierlee@lostmoment.com)
|
* $(HTTP digitalmars.com, Walter Bright),
|
||||||
* Copyright: Copyright Andrei Alexandrescu 2008-, Jonathan M Davis 2011-., 2014-2016 Mike Bierlee
|
* Tomasz Stachowiak ($(D isExpressions)),
|
||||||
|
* $(HTTP erdani.org, Andrei Alexandrescu),
|
||||||
|
* Shin Fujishiro,
|
||||||
|
* $(HTTP octarineparrot.com, Robert Clipsham),
|
||||||
|
* $(HTTP klickverbot.at, David Nadlinger),
|
||||||
|
* Kenji Hara,
|
||||||
|
* Shoichi Kato,
|
||||||
|
* Mike Bierlee (m.bierlee@lostmoment.com)
|
||||||
|
* Copyright: Copyright Digital Mars 2005 - 2009., Copyright Andrei Alexandrescu 2008-, Jonathan M Davis 2011-., 2014-2016 Mike Bierlee
|
||||||
* License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0)
|
* License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module poodinis.polyfill;
|
module poodinis.polyfill;
|
||||||
|
|
||||||
import std.exception;
|
import std.exception;
|
||||||
|
import std.traits;
|
||||||
|
|
||||||
static if (!__traits(compiles, basicExceptionCtors)) {
|
static if (!__traits(compiles, basicExceptionCtors)) {
|
||||||
mixin template basicExceptionCtors()
|
mixin template basicExceptionCtors()
|
||||||
|
@ -33,3 +42,22 @@ static if (!__traits(compiles, basicExceptionCtors)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static if (!__traits(compiles, isFunction)) {
|
||||||
|
template isFunction(X...) if (X.length == 1)
|
||||||
|
{
|
||||||
|
static if (is(typeof(&X[0]) U : U*) && is(U == function) ||
|
||||||
|
is(typeof(&X[0]) U == delegate))
|
||||||
|
{
|
||||||
|
// x is a (nested) function symbol.
|
||||||
|
enum isFunction = true;
|
||||||
|
}
|
||||||
|
else static if (is(X[0] T))
|
||||||
|
{
|
||||||
|
// x is a type. Take the type of it and examine.
|
||||||
|
enum isFunction = is(T == function);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
enum isFunction = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue