« first day (1765 days earlier)      last day (1090 days later) » 

2:59 AM
uint8_t rsp[MAX_MESSAGE_LENGTH]; //big enough
Why these two expressions output different Uint8s on MSVC?
1. std::copy(vecRespond.begin(), vecRespond.end(), rsp + rsp_length);
2. std::copy(vecRespond.begin(), vecRespond.end(), (unsigned short*)(rsp + rsp_length));
the type of vecRespond is std::vector<unsigned short>
Here are some hints:
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xutility(2414): warning C4244: '=': conversion from 'unsigned short' to '_Ty', possible loss of data
1> with
1> [
1> _Ty=uint8_t
1> ]
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\xutility(2434): note: see reference to function template instantiation '_OutIt std::_Copy_unchecked1<_InIt,_OutIt>(_InIt,_InIt,_OutIt,std::_General_ptr_iterator_tag)' being compiled
Sorry for disturbing. I think I find the answer.
template<class InputIt, class OutputIt>
OutputIt copy(InputIt first, InputIt last,
OutputIt d_first)
{
while (first != last) {
*d_first++ = *first++;
}
return d_first;
}
 
 
2 hours later…
5:13 AM
whenever i try to render multiple shapes they use the first world matrix and get drawn ontop of each other even though each has his own matrix
pieces from this code like uploadbuffer taken from luna frank
> std::unique_ptr<UploadBuffer<ObjectConstants>>mObjectCB ;
> mObjectCB = std::make_unique<UploadBuffer<ObjectConstants>>(m_pDevice.Get(), 2, true);
>struct RenderItem{std::unique_ptr<DirectX::GeometricPrimitive> GeomPrim;DirectX::XMMATRIX World;UINT ObjCBIndex = -1;}
// this how i create shapes
 
 
1 hour later…
6:24 AM
How to apply a specified function object to each element in a source range besides using std::transform?
 
@John just use a normal loop? or rewrite something like std::transform yourself?
or use ranges transform
or std::for_each , there's so many to choose from
 
6:39 AM
@PeterT Any method besides std::transform and norm for loop?
 
like I said ranges transform, std::for_each or write your own function
you can also abuse std::find_if , any_of, none_of , etc. to do the same, because they all can pass in mutable references, not that this is a good idea, but you can do it
 
@PeterT If I understand you correctly, ranges transform and STD:: transform are different. Am I right? If so, what's ranges transform?
 
like std::ranges::views::transform en.cppreference.com/w/cpp/ranges/transform_view
 
Thank you so much.
 
 
7 hours later…
1:40 PM
Looks like what I was asking cannot be achieved as is because function template specialization would be needed but it's not allowed; using class instead of functions would probably do it.
 
 
2 hours later…
4:09 PM
I'm writing a bigint class, and I would really like for it to be usable seamlessly with all builtin arithmetic types, by implicit conversion to bigint.
The first thing I tried was writing three constructors: one for the largest signed, one for the largest unsigned and one for the largest float. The problem is that the conversion from every other type is ambiguous.
Then I tried to declare a constructor for every type, redirecting all of them to the three already defined constructors as needed. This approach worked, but it's wildly unelegant, and clutters things up.
Is there a better way to do this? (I'm using c++20)
 
 
5 hours later…
9:04 PM
I managed to do it by writing constructor template limited by concepts. I didn't knew you could use templates with constructors.
 

« first day (1765 days earlier)      last day (1090 days later) »