117 questions
1
vote
1
answer
145
views
I can't get an optional with (cond) ? value : nullopt ... what should I write instead?
Suppose I'm implementing the function returning an std::optional<T>. In that function, I compute some condition, and then want to return either a value, or a nullopt. I can do it like so:
std::...
0
votes
0
answers
56
views
Why the destructor pointer is null in construction vtable?
My code is below:
class GrandParent {
public:
GrandParent() {}
virtual ~GrandParent() {}
int grandparent_data = 100;
};
class Parent1 : virtual public GrandParent {
public:
Parent1() {}...
1
vote
2
answers
84
views
Construct a variadic std::tuple using a parameter pack of constructor arguments
I have the following class definitions. I would like to create an Alphabet of Letter classes where each Letter class is constructed using an argument from the parameter pack passed to the Alphabet ...
0
votes
1
answer
154
views
How Can I Represent An Assembly Program With Labels?
I am trying to represent assembly programs in Coq and compile them into a sequence of bytes.
I have an assembly language, a decoder, a compiler, and proof that the decoder is the inverse of the ...
2
votes
2
answers
72
views
Is there a meaningful difference in this '@()' construction or is this a bug?
I have a function whose name parameter I want to provide tab completion for, the tab completion values are file names found in c:\temp. On top of using the files in c:\temp as values, I also want to ...
-1
votes
1
answer
136
views
CodeForces Contest > 1761 \ Problem C (Set Construction) - How to solve this problem?
Guys I have been working on this problem since morning (4 hours ago) and still couldn't find a proper answer. How can I set the Subsets with these conditions? So for example an A Set is a subset of A2 ...
0
votes
1
answer
47
views
https://github.com/autodesk-platform-services/aps-industrial-construction-explored. mongoDB GOT connected successfully. NOTHING PROGRESSES FROM THEN
We are keen to have 3D model overlay on Google map and handle the click event so show the graphs viz temperature and pressure realtime data.
Also, the issues reported by the system to be notified to ...
0
votes
1
answer
90
views
C++ - Interaction between move construction and forwarding
If I'm constructing a non-trivial container like a custom map for example,
and want to share code between the emplace and insert functions, one approach would be to have the insert function simply ...
0
votes
0
answers
106
views
Dart initialization and final, final late
Hi developers!I'm using Dart for flutter. I'm trying to figure out why the code below doesn't need 'late' or 'final' for its variables. I know what these terms mean, but I'm puzzled about when and ...
2
votes
1
answer
107
views
Haskell fast construction of vector from input of space separated ints
If I expect a string with space separated ints from user input (number of expected int's known), I can transfer it in haskell Data.Vector like this:
main = do
n <- readLn -- this is number ...
3
votes
2
answers
958
views
Construction vs Initialisation Formal difference
I am learning C++ using the books listed here. Now I came across the following statement from C++ Primer:
When we allocate a block of memory, we often plan to construct objects in that
memory as ...
1
vote
3
answers
364
views
How do I initialize all elements of TrieNodes' children to null
I am trying to solve a Trie problem, for which I create a TrieNode class as below:
class TrieNode {
public:
bool isWord;
TrieNode* children[26];
TrieNode() {
isWord=false;
...
8
votes
2
answers
309
views
Can a C++ constructor know whether it's constructing a const object?
In C++, object constructors cannot be const-qualified.
But - can the constructor of an object of class A know whether it's constructing a const A or a non-const A?
Motivated by a fine point in the ...
9
votes
1
answer
2k
views
How to in-place-construct an optional aggregate?
How to in-place construct an optional aggregate? It seems I can only construct an optional single thing, and not an optional aggregate of things.
#include <optional>
#include <iostream>
...
0
votes
0
answers
97
views
Woocommerce plugin causing redirect
i'm using woocommerce to create a store for my shop in WordPress but whenever I activate the woocommerce plugin the page redirect with this message "ERR_TOO_MANY_REDIRECTS", then when I ...
0
votes
0
answers
48
views
How to make a rigid alternative constraint based on earn value
i want to make a rescheduling model. I have 2 modes in tuple, I declare it using ID, I want to make a constraint if the costprod * duration in present's mode in day 1-7 <= earn value than choose ...
0
votes
1
answer
142
views
How to define cost objective function
I want to make objective function to minimize impact due to the difference progress with schedule plan because the real progress was late. and I want make it some with the plan
minimize the external ...
1
vote
1
answer
55
views
Haskell Converting paramaters into type
I have created the type Contact, and I'm trying to create a function that takes 4 parameters (First Name, Last Name, Phone and State) and creates a contact and adds it to a list of existing contact.
...
0
votes
2
answers
127
views
If else on the date in CPLEX OPL
I want to make, if total production task "i" * duration at day 15 <= not equal to our target then choose alternative 2,else choose alternative 1. I made the data on tuple. but I still ...
0
votes
2
answers
266
views
How to make a if and else in alternative function in OPL?
I want to make if the earn value is not same with the plan then choose alternative 2, if same then choose alternative 1. I used tuple mode to determine the 2 alternative in OPL using CP(constraint ...
0
votes
1
answer
310
views
Using Lisp: Write a Common Lisp function named myList which creates the following list and returns it
This was the list given:
(4 (7 22) "art" ("math" (8) 99) 100)
but I'm still having trouble coming up with the correct code in order to answer this problem
all I have come up with ...
6
votes
2
answers
243
views
Are the following 3 ways to define objects identical?
In my understanding the following are identical:
Person p{}; // Case 1
Person p = {}; // Case 1.5
I noticed
Person p = Person{}; // Case 2
produces the same tracing output as the Case 1 and Case 1.5 ...
3
votes
4
answers
801
views
Deserialize a binary tree breadth-first in Functional Programming
I had an imperative program which deserializes to a Binary Tree from an array. Its a BFS algorithm. I was wondering how to do this in Scala with functional programming concepts.
class TreeNode(...
7
votes
3
answers
3k
views
Building a Binary Tree (not BST) in Haskell Breadth-First
I recently started using Haskell and it will probably be for a short while. Just being asked to use it to better understand functional programming for a class I am taking at Uni.
Now I have a slight ...
1
vote
2
answers
10k
views
Is It Safe to Put a Java Enum in a Static Map During Its Construction Call?
As the title reads, I have the following Enum:
public enum MyEnum {
FIRST_ENUM("first enum"),
SECOND_ENUM("second enum"),
THIRD_ENUM("third enum"),
FORTH_ENUM("forth enum");
private final ...
0
votes
1
answer
51
views
Would the C++11 targeted constructor allow me to safely initialize derived class from template constructor?
I have a variety of objects created from template class bar (below). Each object has a data member with different data type (eg std::string, bool, int, etc.)
I have a set of current defaults of each ...
0
votes
4
answers
352
views
Multiple calling constructor will change the member pointer address in C++
I write a program to check the init process of class creation, and found calling the constructor multiple times changed the member pointer address. Look at following snippet.
#include <iostream>...
-1
votes
1
answer
51
views
Is there a Pythonic way to create a list of cloned items? [duplicate]
Consider the following code:
class SomeClass:
def __init__(self):
self.foo = None
some_list = [SomeClass()] * 5
The problem with this code is that all 5 items of some_list refer to the ...
0
votes
1
answer
55
views
DefaultConstructionHeuristicPhase - workingScoreHolder holds invalid score of not accepted move
I build a VRP solution based on optaplanner 7.4.1. using a default construction heuristic "FIRST_FIT_DECREASING". In the ConstructionHeuristicDecider I can see now, that at the end of method ...
0
votes
1
answer
356
views
Tools for Java template-based String construction
I am trying to refactor some legacy code. The task here is to construct lengthy messages/strings based on some pre-defined template that looks like this:
field1,8,String
filed2,5,Integer
field3,12,...
0
votes
2
answers
258
views
migrating from calloc() to new
I came across a large pod struct, in which I wanted to add a std::vector member.
struct LargePodStruct {
float x,y,z;
int *arr;
int sz;
... // dozens of primitive types
...
1
vote
1
answer
172
views
construction of bst from preorder traversal
While constructing Binary search tree from given Preorder traversal, can't we use normal method for construction of BST from set of array values instead of following the method given here. If not ,...
-7
votes
3
answers
55
views
Name of construction [closed]
private final EventManager eventManager;
private final DateManager dateManager;
private final UserManager userManager;
What is the name of this construction? Is this object or something else?
...
1
vote
3
answers
84
views
Constructing an object as part of ostream output
For a class declaration as below:
class A{
public:
A(int);
~A()
private:
int a;
};
And a constructor definition as follows:
A::A(int i){
a = i;
cout << a << endl;
}
I would like to do ...
1
vote
2
answers
240
views
Cannot create class in AHK after destruction
I'm trying to wrap my head around classes in AHK. I'm C++ dev, so would like to make use of RAII (__New, __Delete), but it looks like I miss some concepts since things look very contra-intuitive for ...
0
votes
0
answers
25
views
A list in a class seems to be static? [duplicate]
In a Python class I wrote the following method:
class user():
address_list = []
def __init__(self):
self.address_list.append("a")
When I use it as this:
ur1 = user()
ur1....
0
votes
3
answers
82
views
SomeInterface <SomeClass<A, B>> Java - how use this construction correctly?
First of all I have following class:
public class Pair <K, V> {
public K key;
public V value;
public Pair (K key, V value){
this.key = key; this.value = value;
}}
and an interface:
...
0
votes
1
answer
43
views
Diffrent outputs caused by a " irrelevant " statement in graph construction (symbolic style programs ) in tensorflow
I have a basic issue about the symbolic style programs in tensorflow, below are codes ( tensorflow 0.12 ):
import numpy as np
import tensorflow as tf
import sys
x = tf.placeholder(tf.float32, 1)
y = ...
5
votes
3
answers
3k
views
Idiom to initialize C++ class to zero
Consider the following C++ class:
struct Point
{
int x;
int y;
explicit Point() =default; // 1
explicit Point(int x_, int y_): x(x_), y(y_) { } // 2
};
The second constructor is ...
0
votes
0
answers
455
views
Minimum Variance portfolio optimisation using NLOPTR
I am using SLSQP function in NLOPTR for portfolio construction using 34 low volatility stocks. The stocks are not important. What I am trying to do is being able to impose a minimum weight and a ...
0
votes
0
answers
789
views
How to create words construction
I am trying to create some words construction using custom template, for example I need something like this:
and I don't really know best way to doing this, I want to create labels rotate and place it ...
4
votes
2
answers
336
views
Utilizing move-semantics and element-wise initialization of containers
Often seen that examples of using STL algorithms are illustrated with list-initialized containers like:
std::vector< int > v{1, 2, 3, 4};
But when this approach is used for (heavyweight) ...
6
votes
2
answers
482
views
How to support multiple construction signatures in a factory design?
I'm working with the following (simplified) factory design to create objects of some inheritance hierarchy, shouldn't be anything special:
// class to create
class Class
{
public:
Class(Type type, ...
0
votes
1
answer
2k
views
Text to speak causing application to crash (Android studio)
I'm guessing it's an error with the initiation/construction, but the parameters seem to be the correct ones and I can't find any other issues. Here's the entire activity code. The text to speech ...
0
votes
1
answer
471
views
java.net.URL bug in constructing URLs?
The construct new URL(new URL(new URL("http://localhost:4567"), "abc"), "def") produces (imho incorrectly) this url: http://localhost:4567/def
While the construct new URL(new URL(new URL("http://...
2
votes
1
answer
3k
views
Construct incorrect URLs in java with java.net.URL?
Using oracle java 1.8.0_25
I have the following construct
URL url = new URL(new URL(new URL("http://localhost:4567/"), "123"), "asd")
According the documentation in ...
10
votes
2
answers
338
views
Shouldn't the temporary A(3) be destroyed before "Here" is printed?
Shouldn't the temporary A(3) be destroyed before "Here" gets printed?
#include <iostream>
struct A
{
int a;
A() { std::cout << "A()" << std::endl; }
A(int a) : a(a) { ...
1
vote
0
answers
159
views
Using library(element).function() or library.function() constructions in Javascript lib
We have Javascript library:
(function (global, factory) {
factory(global);
}(window , function() {
var MyLib = function(elem) {
return new MyLib.foo.init(elem);
}
MyLib.foo = {
...
0
votes
2
answers
182
views
construct a matrix in Octave
I have a vector idx = [3; 5; 3; 4; 3; 2; 5; 1]. The number is from 1:k with k = 5. I want to make a "k by m" matrix A (m is the number of elements in the vector idx). Each row of A contains either '0' ...
1
vote
1
answer
27
views
My desire: to continue to edit a redirected page
I'm building my first website from scratch and want to redirect all viewers (mainly the employer for appearances sake) to an "under construction" page. I used the following code in the head:
<meta ...