object-construction Questions

3

Solved

In the question Idiom for initializing an std::array using a generator function taking the index?,which basically asks how one can initialize an array of an arbitrary type which is not necessarily ...
Gribble asked 26/6 at 14:23

2

Suppose I have a function T foo(size_t i). What would be an elegant and succinct way of constructing an object arr, of type std::array<T, N>, so that we have arr[i] == foo(i)? If possible, I ...
Amagasaki asked 26/6 at 12:28

1

Solved

According to cppreference, std::construct_at(T*p, Args&&... args) is equivalent to return ::new (const_cast<void*>(static_cast<const volatile void*>(p))) T(std::forward<Args...
Thisbe asked 9/8, 2020 at 10:36

3

Solved

Could you please explain me what's wrong in the following code? function box (width, height, color) { this.width=width; this.height=height; this.color=color; this.style.width=width; this.style...
Becki asked 20/6, 2020 at 11:18

9

Solved

I'm partial to using member initializer lists for my constructors, but I've long since forgotten the reasons behind this. Do you use member initializer lists in your constructors? If so, why? If no...
Restive asked 29/5, 2009 at 15:56

6

Solved

In my current project (OpenGL Voxel Engine) I have a serious issue when generating models. I have a very object oriented structure, meaning that even single parameters of my vertices are Objects. T...
Coppola asked 10/1, 2014 at 22:0

5

Solved

I've got a class that has a couple of data members of class type. I don't want the constructors for these members to be called when declared, so I'm trying to hang onto a pointer to the object expl...
Thump asked 17/10, 2012 at 4:33

2

Solved

In code like this: #include <iostream> #include <initializer_list> #include <string> struct A { A() { std::cout << "2" << std::endl; } A(int a) { std::cout <&...
Cuttle asked 29/1, 2018 at 8:5

1

Solved

In Perl5 you can do something like this: #!/usr/bin/env perl use 5.010; package Local::Class { use Moo; has [qw( x y )] => ( is => 'ro'); sub BUILDARGS { shift; return (@_) ? (@_ > 1)...
Thremmatology asked 1/12, 2016 at 0:43

5

Solved

Let's say a class has been defined as class A { //..... }; and now I am creating two objects as A a,b; In what order are a and b created? Is it defined by the standard?
Thirtytwomo asked 22/2, 2016 at 18:26

6

Solved

In my application, I have to instantiate many different types of objects. Each type contains some fields and needs to be added to a containing type. How can I do this in an elegant way? My current...
Bainbrudge asked 13/10, 2015 at 15:0

3

If I have the following code, why does it return an error saying Cannot set property 'second_prop' of undefined . I thought that you can extend the prototype property and add more variables and met...
Mel asked 30/4, 2015 at 21:16

2

Solved

By forwarded in-place construction, I take to mean std::allocator::construct and the various emplace methods, e.g., std::vector::emplace_back. I just find that forwarded in-place construction in C+...

5

Let's say I have the following code public class SuperClass { protected int super_class_value; public SuperClass (int value) { this.super_class_value = value; } } public class Subclass exten...
Chlorous asked 11/2, 2015 at 19:58

4

Solved

I woud like to write a JUnit test to verify that the code below uses a BufferedInputStream: public static final FilterFactory BZIP2_FACTORY = new FilterFactory() { public InputStream makeFilter(I...

7

Solved

Does Java has a default copy constructor as C++? If it has one - does it remain usable if I declare another constructor (not a copy constructor) explicitly?

3

Solved

Is the following code undefined behavior, implementation defined or defined by the standard? I couldn't find any reference regarding assigning an integer to its own address. volatile int x = (int)...
Weatherwise asked 11/11, 2013 at 19:41

3

Solved

Observation: the codes pasted below were tested only with GCC 4.4.1, and I'm only interested in them working with GCC. Hello, It wasn't for just a few times that I stumbled into an object constru...
Appomattox asked 16/2, 2010 at 19:22

2

Solved

Please help me to understand why the following code works: <script> var re = RegExp('\\ba\\b') ; alert(re.test('a')) ; alert(re.test('ab')) ; </script> In the first line there is ...
Summertree asked 18/12, 2009 at 13:56
1

© 2022 - 2024 — McMap. All rights reserved.