default-parameters Questions
2
Solved
Consider this code:
#include <functional>
template <typename T,typename COMP>
bool foo(T a,T b,COMP c = std::less<T>()) {
return c(a,b);
}
bool bar(int a, int b){ return a&l...
Klump asked 7/8, 2018 at 9:43
7
Solved
Eclipse Juno keeps opening my HTML files in a embedded web-browser, rather than in an embedded syntax-highlighting editor.
I have installed:
Web Page Editor
Eclipse Web Developer Tools
PyDev for...
Nematic asked 6/8, 2012 at 15:22
5
Solved
I was trying some things today and came across a behaviour I would like to understand.
var b = ({a = 1, b = 1, c = 1}) => a + b + c;
b(); // throws error.
But if it is defined like this
var...
Octarchy asked 3/5, 2018 at 12:7
2
Solved
Amazed (and cofused) by a similar question I tried myself the example that the mentioned question found in the standard:
template <typename T, typename U = int> struct S;
template <typena...
Haya asked 12/3, 2018 at 11:24
3
I stumbled through an example from "Effective C++ in an Embedded Environment" by Scott Meyers where two ways of using default parameters were described: one which was described as costly and the ot...
Rainproof asked 20/2, 2018 at 8:45
3
Solved
PHP 5 Type Hinting
PHP 5 introduces Type Hinting. Functions are now able to force parameters to be objects (by specifying the name of the class in the function prototype) or arrays (since PHP 5.1...
Diffusion asked 15/12, 2011 at 16:4
2
Following code can't be compiled with g++ version 5.4.0 with option -std=c++1y:
void f(int=0) ;
int main() {
f(); // ok
(*f)(2);// ok
(*f)();// ok c++11; error with c++14: too few arguments to...
Numbat asked 30/10, 2017 at 10:48
1
Solved
Can a function's default parameter value be accessed from a function extension, or anywhere else?
fun DieRoll.cheatRoll():Int = roll(min = max -1)
fun roll(min: Int = 1, max: Int = 6): Int = (min...
Colter asked 20/8, 2017 at 20:16
5
Solved
I am using the Scala 2.8 default parameters on a constructor, and for Java compatibility reasons, I wanted a no-arg constructor that uses the default parameters.
This doesn't work for very sensibl...
Jeaniejeanine asked 28/10, 2010 at 18:8
3
Solved
The following line has the error Default argument is not allowed.
public ref class SPlayerObj{
private:
void k(int s = 0){ //ERROR
}
}
Why C++ has no default argument on managed types ?
I wou...
Warfeld asked 16/3, 2013 at 20:31
4
I've been looking around to try to find what the reasoning is behind not including default parameters for functions in Java.
I'm aware that it's possible to simulate the behavior, either with vara...
Gravitt asked 26/11, 2010 at 9:29
4
Solved
I have this script:
CREATE FUNCTION dbo.CheckIfSFExists(@param1 INT, @param2 BIT = 1 )
RETURNS BIT
AS
BEGIN
IF EXISTS ( bla bla bla )
RETURN 1;
RETURN 0;
END
GO
I want to use it in a procedur...
Wickner asked 2/12, 2011 at 15:6
1
enum class E {
One,
Two
};
void foo(E value = decltype(value)::One) {
}
It can be compiled with Clang (3.9), but cannot be compiled with GCC 6.1: value was not declared in this scope.
What co...
Badlands asked 9/11, 2016 at 17:53
2
Solved
Does default template parameter can use "default value" in a way that does NOT start from right?
What is the criteria?
How will the compiler interpret?
For example, I am so surprised that this co...
Rioux asked 25/8, 2016 at 5:26
2
Solved
I am trying to build a reusable JavaScript function that makes use of default parameters. However, the IDE warns me I do something wrong.
The code is this:
function standardAjaxRequest(process_...
Camorra asked 1/6, 2016 at 14:21
6
Solved
I am writing a new python class with a generic function. At one point I have a requirement as follows
def function(a=1):
....
....
print a # here I want a to be 1 if None or nothing is passed
...
Hadrian asked 29/4, 2016 at 7:32
1
Solved
Let's say I have:
fun addInvoker(adder: () -> Int = ::add): Int{
return adder()
}
fun add(num1:Int = 1, num2:Int = 1): Int{
return num1 + num2
}
I get an error since ::add has two paramete...
Legg asked 30/3, 2016 at 0:20
3
I was building an App in react where I found a line in one of the boiler plate projects.
(state = {}) => state
Can anyone explain to me what the above line means?
It's JavaScript ES6 standard.
...
Hanoi asked 20/2, 2016 at 17:17
4
Solved
To my surprise, this one compiles and runs:
class Program
{
static void Main()
{
DoSomething();
}
private const int DefaultValue = 2; // <-- Here, private.
public static void DoSomethin...
Roydd asked 22/12, 2015 at 12:47
4
Solved
I'm new to JavaScript coming from Python background. In Python parameters can be passed as key and value as such:
def printinfo( name, age = 35 ):
print "Name: ", name
print "Age ", age
r...
Reduced asked 21/12, 2015 at 3:41
2
Solved
I recently ran across the following situation:
#include <iostream>
int *p = 0;
int f() {
p = new int(10);
return 0;
}
void g(int x, int *y = p) {
std::cout << y << std::end...
Costermansville asked 26/8, 2015 at 9:9
1
Solved
I changed a paremeter in a function to accept any kind of object using a template but I can't use it in conjunction with other default parameters, is there something I am missing?
#include &...
Lowenstern asked 19/8, 2015 at 21:29
1
Solved
This is a follow-up on this question. The code in the OP question there looked quite reasonable and unambiguous to me. Why does not C++ allow using former parameters to define default values of lat...
Materse asked 30/7, 2015 at 0:8
2
Solved
So... ES6¹ (which happens to be standardized a few hours ago) brings default parameters for functions similar to those in PHP, Python etc. I can do stuff like:
function foo (bar = 'dum') {
return...
Spleen asked 17/6, 2015 at 20:20
2
Solved
I have an abstract class with a default value for its parameter.
I don't want to have to reuse the default value in the constructor of all the possible implementations.
abstract class Place(val pl...
Issie asked 19/5, 2015 at 12:50
© 2022 - 2024 — McMap. All rights reserved.