Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » How to mark std::array<T, N> moveable if only T is moveable
Re: How to mark std::array<T, N> moveable if only T is moveable [message #60714 is a reply to message #60703] Mon, 29 July 2024 08:47 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
mirek wrote on Thu, 25 July 2024 09:32
mirek wrote on Thu, 25 July 2024 09:19

Another thing to consider: Tuple is moveable if all its components are moveable. Are we able to express that somehow? (If not, no big deal, I can make Tuple moveable and request that elements are).


Figured it out:


struct not_moveable {};

template <class A, class B>
class Two : std::conditional<is_moveable<A> && is_moveable<B>, moveable<Two<A, B>>, not_moveable>::type {
	A a;
	B b;
};




Nicer and simpler way:

template <class A, class B> inline constexpr bool is_moveable<Two<A, B>> = is_moveable<A> && is_moveable<B>;


I am about ready to try to introduce this into U++, but I am actually out of ideas how to name things....

Moveable / is_moveable is not perfect (future c++ might name this trivially_relocatable, but that is too long IMO), but u++ traditional, I guess I can live that.

However, new system should introduce a trait that says "I know I cannot memmove this type, but I still would like to store it into Vector anyway". E.g. to have Index<std::string> ... Really not sure what id should I use for that... Something like "is_vector_compatible_but_slower", or "std_moveable" or something?

(alternative would be to have "mem moveable" as option, but I want to force developer to be explicit, not to forget to mark moveable types)

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon14.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Copy the content of a SortedVectorMap
Next Topic: SMTP not working
Goto Forum:
  


Current Time: Thu Aug 07 22:06:37 CEST 2025

Total time taken to generate the page: 0.03794 seconds