« first day (683 days earlier)      last day (2161 days later) » 

6:34 AM
@Permian I would also include knowledge of the compiler and toolchains they use.
 
 
1 hour later…
Ron
7:47 AM
What is &0xffff in this question?
A cast, address of a literal (or I need another coffee)?
Ah, some sort of bitwise operator. Carry on.
 
 
5 hours later…
12:34 PM
I get the following warning: warning C4996: 'std::_Transform1': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
regarding to that function: std::transform(
vertices.begin(),
vertices.end(),
vertices.begin(),
[&local_system](QVector3D& vertex)
{ return local_system.inverted().map(vertex); });
what is unsafe here ?
 
it assumes that vertices.begin() will have enough space after it (but it cannot check that)
however in this case you can use std::for_each
std::transform(vertices.begin(), vertices.end(),
    [&local_system](QVector3D& vertex)
    { vertex = local_system.inverted().map(vertex); })
 
Hello
 
thx ratchet...so it is unclear if there is enough space behind vertices.begin() to store the returned data ?
 
does anyone know how I can limit setter and getter?
a base can set a member in a extended class but the extended only can get that member
The extended class will holt the member itself... I came with incomplete solution which do not compile
 
make setter private
wait what
 
12:44 PM
class Base;

class Extended : public Base
{
  public:
    char m_Val;

    Extended() : ptrExtended(this), m_Val('X') { }

    virtual char& getSomeVal() {
      return m_Val;
    }
};

class Base : public ISet
{
  protected:
    Extended* ptrExtended;

  private:
    // Forward variable to extended class
    virtual void setSomeVal(char refVar) {
        ptrExtended->m_Val = refVar;
    }
};
 
Edit the message and press Ctrl+K
 
updated
 
this doesn't make much sense
 
@millenium updated, also interface is updated too (is only a pure setter)
 
the Base is tightly coupled to the subclass
 
12:48 PM
yes is coupled
 
so the data member could as well be in the base class
 
@ The base contains a pointer to the extended (association)
 
IOW, I can't help but think this is a XY problem
let's say you accomplish this
what next
 
@milleniumbug no it can't be in the base, no variables are required in there (maybe only a ref) (&var)
 
you're not making any sense
 
12:52 PM
Hello!
 
@milleniumbug scenario, let's consider sensor called a
@milleniumbug this only emit (set a value), the network protocol will consume this with a getter
but can't set the sensor value
this value is a variable what can't be hold in the sensor itself only on the network protocol
A is sensor B is the (a box which hold the sensor)
 
looks something like what std::future and std::promise does
 
@LXSoft there is not much reason for them to be different given what you said
 
set value hold nust be only global to (B) but not to A (sensor)
 
 
2 hours later…
2:27 PM
anyone know the best way to check whether the variable i passed in is in utc or local time
 
2:47 PM
I came with a solution
@milleniumbug using CRTP patter but obviously don't work and why that I really dont have an answer, why val does not change
class A
{
public:
    virtual ~A() {};
    virtual void set() = 0;
};

// CRTP pattern implementation for derived classes
template <typename arg_Derived>
class CRTP : public A
{
  public:
    void* addr;

    CRTP()
    {
       (static_cast<arg_Derived&>(*this)).val = 1;
       //(static_cast<arg_Derived&>(*this)).x = 1;
       //(static_cast<arg_Derived&>(*this)).y = 1;
       addr = &(static_cast<arg_Derived&>(*this));
    }

    virtual void set()
    {
      (static_cast<arg_Derived&>(*this)).val = 50;
 
3:23 PM
Finally!
:)
Full complete solution:
allocation was the problem
(static_cast<arg_Derived&>(*this)).val = *new int(value);
 
what the fuck
 
look
class Base
{
public:
    virtual ~Base() {};
    virtual void set(int const&) = 0;
};

// CRTP pattern implementation for derived classes
template <typename arg_Derived>
class Route : public Base
{
  public:
    //void* addr;

    Route()
    {
      // Hard copy
      set(15);
      //(static_cast<arg_Derived&>(*this)).A::val = 1;

      //(static_cast<arg_Derived&>(*this)).x = 1;
      //(static_cast<arg_Derived&>(*this)).y = 1;
      //addr = &(static_cast<arg_Derived&>(*this));
      //((B*)addr)->val;
after 2 hours
:O
I toute through using the beautifull CRTP pattern discovered also by mistake
routed*
 
now throw it into the garbage
 
why?
 
*new is the memory leak operator
 
3:32 PM
but works
works also with
(static_cast<arg_Derived&>(*this)).val = value;
 
failing engine that leaks its fluid also works... until it stops working
 
@milleniumbug :))
@milleniumbug no memory leaks now ;)
Thank you all!
 
3:48 PM
Guys, what should I do if I want to std::forward a member of function parameter? Will this code work?
template<typename U> void doSomething(U&& data) {
	foo(std::forward<U>(data).member);
}
 
 
4 hours later…
8:13 PM
Does anyone know why I am loose the scope on protected members if a class is inherited using protected qualifier?
here is my snippet
class Extended : public Route<Extended>
{
  protected:
    unsigned short int value;

  public:
    Extended() : value(2) {}
    unsigned short int const& getValue() const;
    virtual ~Extended();

};  Extended::~Extended() { }

unsigned short int const& Extended::getValue() const { return value; }

class Update : protected Extended
{
  protected:
    //unsigned short int& m_refValue;
    Extended& m_refExtended;

  public:
    Update(Extended& extendedReference) : /*m_refValue(extendedReference.value),*/ m_refExtended(extendedReference){}
 
@LXSoft "loose the scope" What do you mean? Do you get a compile error? What is the error you get?
 
@Justin Hi, the error is |In member function 'void Update::set(const short unsigned int&)
@Justin short unsigned int Extended::value' is protected
|41|error: within this context
 
8:30 PM
Okay. I'm pretty sure the problem is that you are trying to access m_refExtended.value. You'd be able to access your own this->value, but not m_refExtended. That's a separate Extended value
struct Base {
 protected:
    int i;
 private:
    void g(Base& b, struct Derived& d);
};

struct Derived : Base {
    void f(Base& b, Derived& d) // member function of a derived class
    {
        ++d.i; // okay: the type of d is Derived
        ++i; // okay: the type of the implied '*this' is Derived
//      ++b.i; // error: can't access a protected member through Base
//                 (Otherwise it would be possible to change other derived classes,
//                  like a hypothetical Derived2, base implementation)
 
@Justin I know these rules, but
1. Extended& m_refExtended; is member reference to the class Extended which is protected by protected access modifier (in Update class)
2. class Update : protected Extended also inherits Extended with protected qual
What is the problem there with the encapsulation if no external access to the reference int member is made?
The only access is in the inherited class Update
 
// error: can't access a protected member through Base
//                 (Otherwise it would be possible to change other derived classes,
//                  like a hypothetical Derived2, base implementation)
 
of course set is available in the Update class what can be accessed public but the argument will hold only a const& what cant modify directly data from Extended class
only a rvalue copy will be made
 
nwp
The problem is that you could write a function that takes any class, makes a struct that derives from that class and uses that class to access protected members which would make protected pointless. To prevent that you can only access protected members of the object you inherit, not all objects of that class.
 
set(unsigned short int const& number)
@Justin correct buth the qualifier in example is (struct Derived : Base {) private implicitly
 
8:46 PM
@LXSoft struct Derived : Base is public inheritance (note the struct keyword). class Derived : Base would be private
 
@nwp Thank you for this: q:"To prevent that you can only access protected members of the object you inherit, not all objects of that class."
 
nwp
@nwp *uses that struct to access ...
 
@nwp a stupid little problem interfacing Get and Set only for the specific objects have created me headaches
 

« first day (683 days earlier)      last day (2161 days later) »