design-rationale

Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface?

夙愿已清 提交于 2019-11-28 12:14:33
Why shouldn't C#(or .NET) allow us to put a static/shared method inside an interface? seemingly duplicate from here . but my idea is a bit different one, I just want to put a helper for my plugins(interface) shouldn't C# at least allow this idea? namespace MycComponent { public interface ITaskPlugin : ITaskInfo { string Description { get; } string MenuTree { get; } string MenuCaption { get; } void ShowTask(Form parentForm); void ShowTask(Form parentForm, Dictionary<string, object> pkColumns); ShowTaskNewDelegate ShowTaskNew { set; get; } ShowTaskOpenDelegate ShowTaskOpen { set; get; } // would

Why is it disallowed for partial specialization in a non-type argument to use nested template parameters

本小妞迷上赌 提交于 2019-11-27 20:01:24
I have this code template<int N, bool C = true> struct A; template<int N> struct A<N, !(N % 5)> { /* ... */ }; // should work A<25> a; That is, for numbers N that are divisible by 5 , the compiler should use the partial specialization. But the compiler won't accept that partial specialization, because the Standard requires it to reject such code where a non-type argument of a partial specialization references a parameter and is not simply a parameter (like, A<N, N> would be valid). But what is the reason of doing so? Note that I can simply change my code to a more wordy example and it is valid

Why does std::map operator[] create an object if the key doesn't exist?

回眸只為那壹抹淺笑 提交于 2019-11-26 22:38:48
I'm pretty sure I already saw this question somewhere (comp.lang.c++? Google doesn't seem to find it there either) but a quick search here doesn't seem to find it so here it is: Why does the std::map operator[] create an object if the key doesn't exist? I don't know but for me this seems counter-intuitive if you compare to most other operator[] (like std::vector) where if you use it you must be sure that the index exists. I'm wondering what's the rationale for implementing this behavior in std::map. Like I said wouldn't it be more intuitive to act more like an index in a vector and crash (well

Why is it disallowed for partial specialization in a non-type argument to use nested template parameters

三世轮回 提交于 2019-11-26 20:06:48
问题 I have this code template<int N, bool C = true> struct A; template<int N> struct A<N, !(N % 5)> { /* ... */ }; // should work A<25> a; That is, for numbers N that are divisible by 5 , the compiler should use the partial specialization. But the compiler won't accept that partial specialization, because the Standard requires it to reject such code where a non-type argument of a partial specialization references a parameter and is not simply a parameter (like, A<N, N> would be valid). But what

Why does std::map operator[] create an object if the key doesn&#39;t exist?

你说的曾经没有我的故事 提交于 2019-11-26 09:09:33
问题 I\'m pretty sure I already saw this question somewhere (comp.lang.c++? Google doesn\'t seem to find it there either) but a quick search here doesn\'t seem to find it so here it is: Why does the std::map operator[] create an object if the key doesn\'t exist? I don\'t know but for me this seems counter-intuitive if you compare to most other operator[] (like std::vector) where if you use it you must be sure that the index exists. I\'m wondering what\'s the rationale for implementing this