int Praat_tests (int itest, wchar_t *arg1, wchar_t *arg2, wchar_t *arg3, wchar_t *arg4) { long i, n = wcstol (arg1, NULL, 10); double x; (void) arg1; (void) arg2; (void) arg3; (void) arg4; Melder_clearInfo (); Melder_stopwatch (); switch (itest) { case kPraatTests_CHECK_RANDOM_1009_2009: { NUMrandomRestart (310952); for (i = 1; i <= 1009 * 2009 - 100 + 1; i ++) x = NUMrandomFraction (); MelderInfo_writeLine1 (Melder_double (x)); } break; case kPraatTests_TIME_RANDOM_FRACTION: { for (i = 1; i <= n; i ++) (void) NUMrandomFraction (); } break; case kPraatTests_TIME_SORT: { long m = wcstol (arg2, NULL, 10); long *array = NUMlvector (1, m); for (i = 1; i <= m; i ++) array [i] = NUMrandomInteger (1, 100); Melder_stopwatch (); for (i = 1; i <= n; i ++) NUMsort_l (m, array); NUMlvector_free (array, 1); } break; } MelderInfo_writeLine2 (Melder_single (Melder_stopwatch () / n * 1e9), L" nanoseconds"); MelderInfo_close (); return 1; }
static void permuteRandomly (ExperimentMFC me, long first, long last) { for (long itrial = first; itrial < last; itrial ++) { long jtrial = NUMrandomInteger (itrial, last); long dummy = my stimuli [jtrial]; my stimuli [jtrial] = my stimuli [itrial]; my stimuli [itrial] = dummy; } }
void Strings_randomize (Strings me) { for (long i = 1; i < my numberOfStrings; i ++) { long other = NUMrandomInteger (i, my numberOfStrings); wchar_t *dummy = my strings [other]; my strings [other] = my strings [i]; my strings [i] = dummy; } }
void Permutation_swapOneFromRange (Permutation me, long from, long to, long pos, int forbidsame) { try { long n = Permutation_checkRange (me, &from, &to); long newpos = NUMrandomInteger (from, to); if (newpos == pos && forbidsame) { if (n == 1) { Melder_throw (L"Impossible to satisfy \"forbid same\" constraint within the chosen range."); } while ( (newpos = NUMrandomInteger (from, to)) == pos) { ; } } long tmp = my p[pos]; my p[pos] = my p[newpos]; my p[newpos] = tmp; } catch (MelderError) { Melder_throw (me, ": one from range not swapped."); } }
static void shuffle (int path [], int numberOfCities) { for (long i = 1; i <= numberOfCities; i ++) { int j = NUMrandomInteger (i, numberOfCities); int help = path [i]; path [i] = path [j]; path [j] = help; } path [0] = path [numberOfCities]; }
void Polygon_randomize (Polygon me) { for (long i = 1; i <= my numberOfPoints; i ++) { long j = NUMrandomInteger (i, my numberOfPoints); double xdum = my x [i]; double ydum = my y [i]; my x [i] = my x [j]; my y [i] = my y [j]; my x [j] = xdum; my y [j] = ydum; } }
void Permutation_permuteRandomly_inline (Permutation me, long from, long to) { try { long n = Permutation_checkRange (me, &from, &to); if (n == 1) { return; } for (long i = from; i < to; i++) { long newpos = NUMrandomInteger (from, to); long pi = my p[i]; my p[i] = my p[newpos]; my p[newpos] = pi; } } catch (MelderError) { Melder_throw (me, ": not permuted randomly."); } }
int Praat_tests (int itest, char32 *arg1, char32 *arg2, char32 *arg3, char32 *arg4) { int64 n = Melder_atoi (arg1); double t; (void) arg1; (void) arg2; (void) arg3; (void) arg4; Melder_clearInfo (); Melder_stopwatch (); switch (itest) { case kPraatTests_TIME_RANDOM_FRACTION: { for (int64 i = 1; i <= n; i ++) (void) NUMrandomFraction (); t = Melder_stopwatch (); } break; case kPraatTests_TIME_RANDOM_GAUSS: { for (int64 i = 1; i <= n; i ++) (void) NUMrandomGauss (0.0, 1.0); t = Melder_stopwatch (); } break; case kPraatTests_TIME_SORT: { long m = Melder_atoi (arg2); long *array = NUMvector <long> (1, m); for (int64 i = 1; i <= m; i ++) array [i] = NUMrandomInteger (1, 100); Melder_stopwatch (); for (int64 i = 1; i <= n; i ++) NUMsort_l (m, array); t = Melder_stopwatch (); NUMvector_free (array, 1); } break; case kPraatTests_TIME_INTEGER: { double sum = 0; for (int64 i = 1; i <= n; i ++) sum += i * (i - 1) * (i - 2); t = Melder_stopwatch (); MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT: { double sum = 0.0, fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += fi * (fi - 1.0) * (fi - 2.0); t = Melder_stopwatch (); MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT_TO_UNSIGNED_BUILTIN: { uint64_t sum = 0; double fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += (uint32_t) fi; t = Melder_stopwatch (); // 2.59 // 1.60 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT_TO_UNSIGNED_EXTERN: { uint64_t sum = 0; double fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += (uint32_t) ((int32_t) (fi - 2147483648.0) + 2147483647L + 1); t = Melder_stopwatch (); // 1.60 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_UNSIGNED_TO_FLOAT_BUILTIN: { double sum = 0.0; uint32_t nu = (uint32_t) n; for (uint32_t iu = 1; iu <= nu; iu ++) sum += (double) iu; t = Melder_stopwatch (); // 1.35 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_UNSIGNED_TO_FLOAT_EXTERN: { double sum = 0.0; uint32_t nu = (uint32_t) n; for (uint32_t iu = 1; iu <= nu; iu ++) sum += (double) (int32_t) (iu - 2147483647L - 1) + 2147483648.0; t = Melder_stopwatch (); // 0.96 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_STRING_MELDER_32: { autoMelderString string; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { MelderString_copy (& string, word); for (int j = 1; j <= 30; j ++) MelderString_append (& string, word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_S: { std::string s = ""; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_C: { std::basic_string<char> s = ""; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_WS: { std::wstring s = L""; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_WC: { std::basic_string<wchar_t> s = L""; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_32: { std::basic_string<char32_t> s = U""; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_U32STRING: { #if ! defined (macintosh) || ! useCarbon std::u32string s = U""; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } #endif t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRCPY: { char buffer [100]; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { strcpy (buffer, word); for (int j = 1; j <= 30; j ++) strcpy (buffer + strlen (buffer), word); } t = Melder_stopwatch (); MelderInfo_writeLine (Melder_peek8to32 (buffer)); } break; case kPraatTests_TIME_WCSCPY: { wchar_t buffer [100]; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { wcscpy (buffer, word); for (int j = 1; j <= 30; j ++) wcscpy (buffer + wcslen (buffer), word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STR32CPY: { char32 buffer [100]; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { str32cpy (buffer, word); for (int j = 1; j <= 30; j ++) str32cpy (buffer + str32len (buffer), word); } t = Melder_stopwatch (); MelderInfo_writeLine (buffer); } break; case kPraatTests_TIME_GRAPHICS_TEXT_TOP: { autoPraatPicture picture; for (int64 i = 1; i <= n; i ++) { Graphics_textTop (GRAPHICS, false, U"hello world"); } t = Melder_stopwatch (); } break; } MelderInfo_writeLine (Melder_single (t / n * 1e9), U" nanoseconds"); MelderInfo_close (); return 1; }
void ExperimentMFC_start (ExperimentMFC me) { try { long maximumStimulusPlaySamples, maximumResponsePlaySamples, maximumPlaySamples; long stimulusCarrierBeforeSamples = 0, stimulusCarrierAfterSamples = 0, maximumStimulusSamples = 0; long responseCarrierBeforeSamples = 0, responseCarrierAfterSamples = 0, maximumResponseSamples = 0; Melder_warningOff (); my trial = 0; NUMvector_free <long> (my stimuli, 1); NUMvector_free <long> (my responses, 1); NUMvector_free <double> (my goodnesses, 1); NUMvector_free <double> (my reactionTimes, 1); my playBuffer.reset(); my pausing = false; my numberOfTrials = my numberOfDifferentStimuli * my numberOfReplicationsPerStimulus; my stimuli = NUMvector <long> (1, my numberOfTrials); my responses = NUMvector <long> (1, my numberOfTrials); my goodnesses = NUMvector <double> (1, my numberOfTrials); my reactionTimes = NUMvector <double> (1, my numberOfTrials); /* * Read all the sounds. They must all have the same sampling frequency and number of channels. */ my samplePeriod = 0.0; my numberOfChannels = 0; if (my stimuliAreSounds) { if (my stimulusCarrierBefore. name && my stimulusCarrierBefore. name [0]) { readSound (me, my stimulusFileNameHead, my stimulusFileNameTail, my stimulusMedialSilenceDuration, & my stimulusCarrierBefore. name, & my stimulusCarrierBefore. sound); stimulusCarrierBeforeSamples = my stimulusCarrierBefore. sound -> nx; } if (my stimulusCarrierAfter. name && my stimulusCarrierAfter. name [0]) { readSound (me, my stimulusFileNameHead, my stimulusFileNameTail, my stimulusMedialSilenceDuration, & my stimulusCarrierAfter. name, & my stimulusCarrierAfter. sound); stimulusCarrierAfterSamples = my stimulusCarrierAfter. sound -> nx; } for (long istim = 1; istim <= my numberOfDifferentStimuli; istim ++) { readSound (me, my stimulusFileNameHead, my stimulusFileNameTail, my stimulusMedialSilenceDuration, & my stimulus [istim]. name, & my stimulus [istim]. sound); if (my stimulus [istim]. sound -> nx > maximumStimulusSamples) maximumStimulusSamples = my stimulus [istim]. sound -> nx; } } if (my responsesAreSounds) { if (my responseCarrierBefore. name && my responseCarrierBefore. name [0]) { readSound (me, my responseFileNameHead, my responseFileNameTail, my responseMedialSilenceDuration, & my responseCarrierBefore. name, & my responseCarrierBefore. sound); responseCarrierBeforeSamples = my responseCarrierBefore. sound -> nx; } if (my responseCarrierAfter. name && my responseCarrierAfter. name [0]) { readSound (me, my responseFileNameHead, my responseFileNameTail, my responseMedialSilenceDuration, & my responseCarrierAfter. name, & my responseCarrierAfter. sound); responseCarrierAfterSamples = my responseCarrierAfter. sound -> nx; } for (long iresp = 1; iresp <= my numberOfDifferentResponses; iresp ++) { readSound (me, my responseFileNameHead, my responseFileNameTail, my responseMedialSilenceDuration, & my response [iresp]. name, & my response [iresp]. sound); if (my response [iresp]. sound -> nx > maximumResponseSamples) maximumResponseSamples = my response [iresp]. sound -> nx; } } /* * Create the play buffer. */ maximumStimulusPlaySamples = lround (my stimulusInitialSilenceDuration / my samplePeriod) + lround (my stimulusFinalSilenceDuration / my samplePeriod) + stimulusCarrierBeforeSamples + maximumStimulusSamples + stimulusCarrierAfterSamples + 2; maximumResponsePlaySamples = lround (my responseInitialSilenceDuration / my samplePeriod) + lround (my responseFinalSilenceDuration / my samplePeriod) + responseCarrierBeforeSamples + maximumResponseSamples + responseCarrierAfterSamples + 2; maximumPlaySamples = maximumStimulusPlaySamples > maximumResponsePlaySamples ? maximumStimulusPlaySamples : maximumResponsePlaySamples; my playBuffer = Sound_create (my numberOfChannels, 0.0, maximumPlaySamples * my samplePeriod, maximumPlaySamples, my samplePeriod, 0.5 * my samplePeriod); /* * Determine the order in which the stimuli will be presented to the subject. */ if (my randomize == kExperiment_randomize_CYCLIC_NON_RANDOM) { for (long itrial = 1; itrial <= my numberOfTrials; itrial ++) my stimuli [itrial] = (itrial - 1) % my numberOfDifferentStimuli + 1; } else if (my randomize == kExperiment_randomize_PERMUTE_ALL) { for (long itrial = 1; itrial <= my numberOfTrials; itrial ++) my stimuli [itrial] = (itrial - 1) % my numberOfDifferentStimuli + 1; permuteRandomly (me, 1, my numberOfTrials); } else if (my randomize == kExperiment_randomize_PERMUTE_BALANCED) { for (long ireplica = 1; ireplica <= my numberOfReplicationsPerStimulus; ireplica ++) { long offset = (ireplica - 1) * my numberOfDifferentStimuli; for (long istim = 1; istim <= my numberOfDifferentStimuli; istim ++) my stimuli [offset + istim] = istim; permuteRandomly (me, offset + 1, offset + my numberOfDifferentStimuli); } } else if (my randomize == kExperiment_randomize_PERMUTE_BALANCED_NO_DOUBLETS) { for (long ireplica = 1; ireplica <= my numberOfReplicationsPerStimulus; ireplica ++) { long offset = (ireplica - 1) * my numberOfDifferentStimuli; for (long istim = 1; istim <= my numberOfDifferentStimuli; istim ++) my stimuli [offset + istim] = istim; do { permuteRandomly (me, offset + 1, offset + my numberOfDifferentStimuli); } while (ireplica != 1 && my stimuli [offset + 1] == my stimuli [offset] && my numberOfDifferentStimuli > 1); } } else if (my randomize == kExperiment_randomize_WITH_REPLACEMENT) { for (long itrial = 1; itrial <= my numberOfTrials; itrial ++) my stimuli [itrial] = NUMrandomInteger (1, my numberOfDifferentStimuli); } Melder_warningOn (); } catch (MelderError) { Melder_warningOn (); my numberOfTrials = 0; NUMvector_free (my stimuli, 1); my stimuli = nullptr; Melder_throw (me, U": not started."); } }
int Praat_tests (int itest, char32 *arg1, char32 *arg2, char32 *arg3, char32 *arg4) { int64 n = Melder_atoi (arg1); double t = 0.0; (void) arg1; (void) arg2; (void) arg3; (void) arg4; Melder_clearInfo (); Melder_stopwatch (); switch (itest) { case kPraatTests_TIME_RANDOM_FRACTION: { for (int64 i = 1; i <= n; i ++) (void) NUMrandomFraction (); t = Melder_stopwatch (); } break; case kPraatTests_TIME_RANDOM_GAUSS: { for (int64 i = 1; i <= n; i ++) (void) NUMrandomGauss (0.0, 1.0); t = Melder_stopwatch (); } break; case kPraatTests_TIME_SORT: { long m = Melder_atoi (arg2); long *array = NUMvector <long> (1, m); for (int64 i = 1; i <= m; i ++) array [i] = NUMrandomInteger (1, 100); Melder_stopwatch (); for (int64 i = 1; i <= n; i ++) NUMsort_l (m, array); t = Melder_stopwatch (); NUMvector_free (array, 1); } break; case kPraatTests_TIME_INTEGER: { int64 sum = 0; for (int64 i = 1; i <= n; i ++) sum += i * (i - 1) * (i - 2); t = Melder_stopwatch (); MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT: { double sum = 0.0, fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += fi * (fi - 1.0) * (fi - 2.0); t = Melder_stopwatch (); MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT_TO_UNSIGNED_BUILTIN: { uint64_t sum = 0; double fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += (uint32) fi; t = Melder_stopwatch (); // 2.59 // 1.60 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT_TO_UNSIGNED_EXTERN: { uint64_t sum = 0; double fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += (uint32) ((int32) (fi - 2147483648.0) + 2147483647L + 1); t = Melder_stopwatch (); // 1.60 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_UNSIGNED_TO_FLOAT_BUILTIN: { double sum = 0.0; uint32 nu = (uint32) n; for (uint32 iu = 1; iu <= nu; iu ++) sum += (double) iu; t = Melder_stopwatch (); // 1.35 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_UNSIGNED_TO_FLOAT_EXTERN: { double sum = 0.0; uint32 nu = (uint32) n; for (uint32 iu = 1; iu <= nu; iu ++) sum += (double) (int32) (iu - 2147483647L - 1) + 2147483648.0; t = Melder_stopwatch (); // 0.96 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_STRING_MELDER_32: { autoMelderString string; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { MelderString_copy (& string, word); for (int j = 1; j <= 30; j ++) MelderString_append (& string, word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_MELDER_32_ALLOC: { char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { autoMelderString string; MelderString_copy (& string, word); for (int j = 1; j <= 30; j ++) MelderString_append (& string, word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_S: { std::string s = ""; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_C: { std::basic_string<char> s = ""; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_WS: { std::wstring s = L""; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_WC: { std::basic_string<wchar_t> s = L""; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_32: { std::basic_string<char32_t> s = U""; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_U32STRING: { std::u32string s = U""; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRCPY: { char buffer [100]; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { strcpy (buffer, word); for (int j = 1; j <= 30; j ++) strcpy (buffer + strlen (buffer), word); } t = Melder_stopwatch (); MelderInfo_writeLine (Melder_peek8to32 (buffer)); } break; case kPraatTests_TIME_WCSCPY: { wchar_t buffer [100]; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { wcscpy (buffer, word); for (int j = 1; j <= 30; j ++) wcscpy (buffer + wcslen (buffer), word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STR32CPY: { char32 buffer [100]; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { str32cpy (buffer, word); for (int j = 1; j <= 30; j ++) str32cpy (buffer + str32len (buffer), word); } t = Melder_stopwatch (); MelderInfo_writeLine (buffer); } break; case kPraatTests_TIME_GRAPHICS_TEXT_TOP: { autoPraatPicture picture; for (int64 i = 1; i <= n; i ++) { Graphics_textTop (GRAPHICS, false, U"hello world"); } t = Melder_stopwatch (); } break; case kPraatTests_THING_AUTO: { int numberOfThingsBefore = theTotalNumberOfThings; { Melder_casual (U"1\n"); autoDaata data = Thing_new (Daata); Thing_setName (data.get(), U"hello"); Melder_casual (U"2\n"); testData (data.get()); testAutoData (data.move()); autoDaata data18 = Thing_new (Daata); testAutoData (data18.move()); fprintf (stderr, "3\n"); autoDaata data2 = newAutoData (); fprintf (stderr, "4\n"); autoDaata data3 = newAutoData (); fprintf (stderr, "5\n"); //data2 = data; // disabled l-value copy assignment from same class fprintf (stderr, "6\n"); autoOrdered ordered = Thing_new (Ordered); fprintf (stderr, "7\n"); //data = ordered; // disabled l-value copy assignment from subclass data = ordered.move(); //ordered = data; // disabled l-value copy assignment from superclass //ordered = data.move(); // assignment from superclass to subclass is rightfully refused by compiler fprintf (stderr, "8\n"); data2 = newAutoData (); fprintf (stderr, "8a\n"); autoDaata data5 = newAutoData (); fprintf (stderr, "8b\n"); data2 = data5.move(); fprintf (stderr, "9\n"); //ordered = data; // rightfully refused by compiler fprintf (stderr, "10\n"); //autoOrdered ordered2 = Thing_new (Daata); // rightfully refused by compiler fprintf (stderr, "11\n"); autoDaata data4 = Thing_new (Ordered); // constructor fprintf (stderr, "12\n"); //autoDaata data6 = data4; // disabled l-value copy constructor from same class fprintf (stderr, "13\n"); autoDaata data7 = data4.move(); fprintf (stderr, "14\n"); autoOrdered ordered3 = Thing_new (Ordered); autoDaata data8 = ordered3.move(); fprintf (stderr, "15\n"); //autoDaata data9 = ordered; // disabled l-value copy constructor from subclass fprintf (stderr, "16\n"); autoDaata data10 = data7.move(); fprintf (stderr, "17\n"); autoDaata data11 = Thing_new (Daata); // constructor, move assignment, null destructor fprintf (stderr, "18\n"); data11 = Thing_new (Ordered); fprintf (stderr, "19\n"); testAutoDataRef (data11); fprintf (stderr, "20\n"); //data11 = nullptr; // disabled implicit assignment of pointer to autopointer fprintf (stderr, "21\n"); } int numberOfThingsAfter = theTotalNumberOfThings; fprintf (stderr, "Number of things: before %d, after %d\n", numberOfThingsBefore, numberOfThingsAfter); #if 1 MelderCallback<void,structDaata>::FunctionType f; typedef void (*DataFunc) (Daata); typedef void (*OrderedFunc) (Ordered); DataFunc dataFun; OrderedFunc orderedFun; MelderCallback<void,structDaata> dataFun2 (dataFun); MelderCallback<void,structOrdered> orderedFun2 (orderedFun); MelderCallback<void,structDaata> dataFun3 (orderedFun); //MelderCallback<void,structOrdered> orderedFun3 (dataFun); // rightfully refused by compiler autoDaata data = Thing_new (Daata); dataFun3 (data.get()); #endif } break; } MelderInfo_writeLine (Melder_single (t / n * 1e9), U" nanoseconds"); MelderInfo_close (); return 1; }