- Trying to manipulate dynamic_cast - 1 Update
- Why does string.replace not return an iterator? - 1 Update
- What is this header good for ? - 6 Updates
Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>: Nov 02 04:12PM -0700 On Tuesday, November 1, 2022 at 2:24:32 PM UTC, Öö Tiib wrote: > but if programmers use those in their code then the behaviour of resulting > program is undefined if it compiles. That is not just pedantry, outcome can > actually behave in rather confusing manner. The Standard says that identifiers containing a double underscore are reserved. The Standard also tells all about integer promotion, and lots of other stuff too such as an array decaying to a pointer to its first element. The people taking the quiz are expected to be fairly familiar with the Standard, and they can read it while taking the quiz. > On any case use spellchecker on texts you publish ... for example it is spelled > "plagiarism" not "plagarism". I am strongly adverse to spelling standardisation as it curbs creativity. For example if I'm in a happy mood, I will spell 'sheep' with an I instead of an E, as follows: "Today I am so happi, not to be following everyone in the crowd like a mindless shiip, and instead to inject my creativitii into my spelling" During the festive season I use camel case. I had one lecturer in college who could do mirror writing. |
Marcel Mueller <news.5.maazl@spamgourmet.org>: Nov 02 10:32PM +0100 The iterator based erase and insert functions of std::string return an updated iterator because any modifying function invalidates all iterators. string.replace does not. This makes it more complicated and badly readable to apply multiple replacements to a string. Why this asymmetry? Marcel |
Bonita Montero <Bonita.Montero@gmail.com>: Nov 02 03:59AM +0100 Am 01.11.2022 um 20:23 schrieb Alf P. Steinbach: > On 1 Nov 2022 15:32, Bonita Montero wrote: >> #if defined(__cpp_concpets) > That loooks lik a speling eror. That's a feature-test macro defined by C++20. > A good-for-nothing header then. Thanks for your effort to have a deep understanding of my code. ! |
Bonita Montero <Bonita.Montero@gmail.com>: Nov 02 04:02AM +0100 That's the final version of my header, now it requires C++20: #pragma once #include <type_traits> template<typename T> requires std::is_trivially_destructible_v<T> union ndi_t { ndi_t(); ndi_t( T const &init ); ndi_t &operator =( T const &assign ); operator T &(); T *operator &(); T *operator ->() requires std::is_class_v<T>; private: union U { U(); U( T const &value ); T m_value; } m_u; }; template<typename T> requires std::is_trivially_destructible_v<T> inline ndi_t<T>::U::U() { } template<typename T> requires std::is_trivially_destructible_v<T> inline ndi_t<T>::U::U( T const &value ) : m_value( value ) { } template<typename T> requires std::is_trivially_destructible_v<T> inline ndi_t<T>::ndi_t() : m_u() { } template<typename T> requires std::is_trivially_destructible_v<T> inline ndi_t<T>::ndi_t( T const &init ) : m_u( init ) { } template<typename T> requires std::is_trivially_destructible_v<T> inline ndi_t<T> & ndi_t<T>::operator =( T const &assign ) { m_u.value = assign; return *this; } template<typename T> requires std::is_trivially_destructible_v<T> inline ndi_t<T>::operator T &() { return m_u.m_value; } template<typename T> requires std::is_trivially_destructible_v<T> inline T *ndi_t<T>::operator &() { return &m_u.m_value; } template<typename T> requires std::is_trivially_destructible_v<T> inline T *ndi_t<T>::operator ->() requires std::is_class_v<T> { return &m_u.m_value; } |
Tony Oliver <guinness.tony@gmail.com>: Nov 02 04:45AM -0700 On Wednesday, 2 November 2022 at 02:59:13 UTC, Bonita Montero wrote: > >> #if defined(__cpp_concpets) > > That loooks lik a speling eror. > That's a feature-test macro defined by C++20. No, it isn't. You seem to be trying (and failing) to spell "__cpp_concepts". "__cpp_concpets" does not appear anywhere in N4860. |
Bonita Montero <Bonita.Montero@gmail.com>: Nov 02 02:33PM +0100 Am 02.11.2022 um 12:45 schrieb Tony Oliver: >> That's a feature-test macro defined by C++20. > No, it isn't. You seem to be trying (and failing) to spell "__cpp_concepts". > "__cpp_concpets" does not appear anywhere in N4860. Ok, I removed it anyway, requiring concepts always now because I'm using a concept which should stop specializations under a certain condition. |
Muttley@dastardlyhq.com: Nov 02 04:59PM On Wed, 2 Nov 2022 04:02:53 +0100 >That's the final version of my header, now it requires C++20: And this explosion in an ASCII factory does what exactly? |
Bonita Montero <Bonita.Montero@gmail.com>: Nov 02 06:45PM +0100 > Bonita Montero <Bonita.Montero@gmail.com> wrote: >> That's the final version of my header, now it requires C++20: > And this explosion in an ASCII factory does what exactly? It's a class that wraps simple types that don't have destructors and omits their default-construction. With that you can f.e. have a vector of ints (vector<ndi_t<int>>) and the ints aren't default-constructed, i.e. their value is arbitrary. That might save a lot of CPU-time if you grow a large vector in one step so that you can omit the initialization if you do it yourself anyway. But there are other standard types like pair<> where the members are also default-initialized. So if you have a vector of such pairs where .first and .second are ndi_t-types this also might save some CPU-time. There are a number of overloaded operators so that you can handle such an ndi_t<>-object nearly the same way you would handle the corresponding type it encapsulates. F.e. you can take the ndi_t<> object's address with & and you get the address of the encapsulated type. Or you can access the members of the encapsulated object if it is a class type with the ->-operator, similar to a smart pointer. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment