Equivalent of std::less for default comparsons operator (<=>) - c++20

Does c++20 defines something similar to std::less for default comparsons operator (<=>).
I would like define some datasructure with customizable comparator as map or unordered_map do.
template <class DefaultComparison = std::??????<Key>,
struct MyContainer ...

std::compare_three_way is what you are looking for.

Related

if-then in kotlin's #JsonProperty?

I want to do something weird... :)
I have a json file that will have either 1 key name OR another keyname. I want to detect which one is actually there, and assign to kotlin variable in class. Only one OR the other will be there. So,
data class CED(
#JsonProperty("rev_env")
var revision: Any? = null,
#JsonProperty("rev")
var revision: Any? = null,
.
.
.
So, either rev_env OR rev will be in the json file, but whichever is there, their mapping always goes to "revision".
Any way to do that?
You can use #JsonAlias.
For example:
data class A(
#JsonAlias(value = ["rev", "rev_env"])
val rev: Any? = null
)

How compare CodeFunction.Access value?

I'm generating methods of partial classes. Using T4 Text Template
At first, I'm looking for extra implemented methods in the interface.
After that, reading access type, calling CodeFunction.Access.
I need compare CodeFunction.Access result.
I tried:
if(extraMethod.Access == vsCMAccessPublic)
if(extraMethod.Access == "vsCMAccessPublic")
no result....
If withdraw <#= extraMethod.Access #> I get vsCMAccessPublic
Answer:
if(extraMethod.Access == EnvDTE.vsCMAccess.vsCMAccessPublic)
or
if(extraMethod.Access == vsCMAccess.vsCMAccessPublic)

Is is possible to define a custom mapping deriving from NgAttr in AngularDart?

I'd like to define a new mapping annotation. For instance, wouldn't it be nice if #NgAttr added the mustache (the braces {{ and }}) automatically if the attribute looks like a controller value? So that it doesn't matter whether I write
<pui-input pattern="{{ctrl.pattern}}" ng-model="ctrl.value">
or
<pui-input pattern="ctrl.pattern" ng-model="ctrl.value">
Is it possible to add a custom mapping to AngularDart? My first approach was to simply derive from NgAttr, but it doesn't work because annotations must not contain methods in Dart:
/**
* When applied as an annotation on a directive field specifies that
* the field is to be mapped to DOM attribute with the provided [attrName].
* The value of the attribute to be treated as a string, equivalent
* to `#` specification.
* If the value of the attribute looks like a property of a controller, it
* is surrounded by a mustache ({{ }}) if it is missing.
*/
class PuiAttr extends AttrFieldAnnotation {
final mappingSpec = '#';
const PuiAttr(String attrName) : super(attrName);
String get attrName => addMustache(super.attrName);
String addMustache(String attrName)
{
if (attrName.indexOf("{{") == 0) // Todo: find a nice regexp
if (attrName.indexOf("\.")>0)
return "{{$attrName}}";
return attrName;
}
}
Please note the mustaches are only an example. My question is whether it's possible to add custom mappings to the standard set #NgAttr, #NgOneWay, #NgTwoWay, #NgOneWayOneTime and #NgCallback.
Any ideas or suggestions?

How to use the attribute rendered in PrimeFaces

I want to know how to use the attribute rendered in PrimeFaces.
Does this piece of code make any sense:
rendered="#{bean.user 1} and #{bean.user 2}"
The rendered attribute only accepts boolean values. It defines if a component will be created in your page DOM. If you set a component as rendered="false", it will not be visible in your website.
And answering your question: that piece of code only makes sense if user1 and user2 are boolean variables in your bean. Also, don't forget the getters and setters for those variables.
Rendered attribute can only accepts Boolean value, or if you use EL expression, it's expression must evaluate to Boolean value like
#{mBean.isTrue} , #{mBean.valueOne eq 1} , #{mBean.valueOne == 1} , #{mBean.stringValue == 'String'} , etc.
Hope it's help.

Clojure: fully qualified name of a function

In Clojure, is there a more elegant way of finding the fully qualified name of a function (known to have meta info) than
(defn fully-qualified-name [fn]
(let [fn-meta (meta fn )
fn-ns (ns-name (:ns fn-meta))
]
(str fn-ns "/" (:name fn-meta))))
A run-time solution is required. Read-time and compile-time solutions are welcome.
(resolve 'foo) returns the Var named "foo", with its fully-qualified name.
how about syntax-quoting ? it does auto-qualification. use ` instead of '
user=> `(inc)
(clojure.core/inc)
user=> `(fn)
(clojure.core/fn)
type gives a fully qualified name, regardless of meta info.
The output of .toString could get you started:
user=> (.toString map)
"clojure.core$map#11af7bb"