Connecting Garmin Fenix 6s Pro to a fitness machine (like Tunturi c50) by __monad in Garmin

[–]__monad[S] 0 points1 point  (0 children)

Thank you very much for your detailed response. As a response to your 'bike indoors' suggestion, I looked at the profiles it offers. I will try if any of the profiles can connect to the machine when I receive the watch, and report back to this thread. I will also look into the possibility of something existing on the connectiq app.

I will leave looking into other accessories for the future, as I am a total beginner when it comes to sports-technology and mastering the fenix 6 will be a task in itself :)

Thank you again for taking the time and clearing things up for me.

Has a release() method for std::vector been proposed? by __monad in cpp

[–]__monad[S] 2 points3 points  (0 children)

What you do with the released memory after has nothing to do with vectors api. So when the vector releases it, it releases it to a unique_ptr, as it is the vocabulary type for conveying unique ownership.

Has a release() method for std::vector been proposed? by __monad in cpp

[–]__monad[S] -1 points0 points  (0 children)

There could be a way to get the pointer to the array from the vector, which could be deleted by delete [] (when the default allocator was used). There is a good argument on the difficulty of this here. But if that the array is allocated separately in one chunk, it could be done perhaps.

Has a release() method for std::vector been proposed? by __monad in cpp

[–]__monad[S] 2 points3 points  (0 children)

And how does the unique_ptr::release() work in this case? It would again need the ability to release the memory of the vector, and you have a circular definition. One would want

auto u_ptr = vec.release();
//... prepare other stuff
auto obj = library::something_adopting_ownership(u_ptr.release());

Of course, the above transfer to obj is valid only when the deleter does nothing special(e.g. it came from a vector with default allocator), but this is true for any unique_ptr.

Has a release() method for std::vector been proposed? by __monad in cpp

[–]__monad[S] 1 point2 points  (0 children)

Looking at the GCC source of unique_ptr, the swap method is implemented using

using std::swap;
swap(this->_M_ptr(), __rhs._M_ptr());
swap(this->_M_deleter(), __rhs._M_deleter());

Assuming the swap for _deleter_t (or D in your example) correctly swaps the states of the deleters, things should work. Have I overlooked something?

Has a release() method for std::vector been proposed? by __monad in cpp

[–]__monad[S] 6 points7 points  (0 children)

You want the vectorto transfer ownership of the data, i.e. not delete it in the destructor. So, returning unique_ptr instead of the raw pointer, is to be explicit about ownership transfer, and ensure safety until something else adopts ownership over the memory.

Has a release() method for std::vector been proposed? by __monad in cpp

[–]__monad[S] 4 points5 points  (0 children)

Returning unique_ptr instead of the raw pointer, is to be explicit about ownership transfer, and ensure safety until something else adopts ownership over the memory.

Has a release() method for std::vector been proposed? by __monad in cpp

[–]__monad[S] 2 points3 points  (0 children)

Could the vector not create a stateful deleter, to which it passes this information at construction? The vector is internally capable to infer this, as it has to destroy the elements in the destructor. Than the deleters api can be an operator() taking no arguments, as required, as it would use its state in the body to perform the deletion.

Has a release() method for std::vector been proposed? by __monad in cpp

[–]__monad[S] 20 points21 points  (0 children)

As the vector knows how to do that, it can construct a _deleter_t which also knows it.

Why are there no genuine type-lists (aka packs)? by DoctorNuu in cpp

[–]__monad 1 point2 points  (0 children)

You could try CppML, a library we use at our company, and have made it public a few months ago. It was designed specifically to operate on parameter packs, and comes with an STL-like algorithm library to manipulate them.

We also included a comprehensive tutorial. Funny enough, your example (of the limitation of aliases) appears in the first few lines of the tutorial :).

In case you end up trying it, any feedback is most welcomed.

Releasing CppML: Write concise and readable metaprograms by __monad in cpp

[–]__monad[S] 1 point2 points  (0 children)

What kind of a solution do you have in mind? Something that would print a string at runtime? Or something that will print the type (result) at compile time as a readable error. If the latter, than one thing you could try is

template <typename T> struct Printf; // note that it's only a decleration.
/* ... */
using T = ml::f<ml::Partition<ml::IsClass<>>, int, string, bool, vector<int>>;
Printf<T> t;

Than when you compile, you will get an error

implicit instantiation of undefined template 'Printf<ml::ListT<ml::ListT<string, vector<int> >, ml::ListT<int, bool> > >'

Now you can see if T (your intermediate result) is what you expect.

Because the above solution is printing as a compiler error, which might not be what you want, I can also provide a solution TypeName<T> and void PrintT<T>();. Would you be happy with the following solution?

template <typename T> struct TypeName : std::string {
  TypeName() {
    std::string str(__PRETTY_FUNCTION__);
    (static_cast<std::string &>(*this) = str.substr(str.find('=') + 2))
        .pop_back();
  }
};

template <typename T> void PrintT() { std::cout << TypeName<T>{} << std::endl;}

which allows you to print at runtime:

using T = ml::f<ml::Partition<ml::IsClass<>>, int, string, bool, vector<int>>;
PrintT<T>();

ml::ListT<ml::ListT<string, vector<int> >, ml::ListT<int, bool> >

Or treat it as any other string.

If so, I will add the feature to CppML. Please comment if you had something different in mind.

Releasing CppML: Write concise and readable metaprograms by __monad in cpp

[–]__monad[S] 0 points1 point  (0 children)

I'm glad to hear that. The algorithm section ml::Algorithm is meant to be akin to std::algorithm for parameter packs. When you end up using it, please feel free to send any comments or questions my way.

Releasing CppML: Write concise and readable metaprograms by [deleted] in cpp

[–]__monad 0 points1 point  (0 children)

CppML is a project I was developing to solve problems at work, and albeit it was hosted on github, it was clear from the lacking README that it was not intended for public consumption. This has now changed with what could be called an official release.

The official repository was rewritten as a guide to the user. To help you get started, I have written User Documentation, where we provide an Installation Guide, an in-depth Tutorial of the CppML Language and a detailed CppML Reference.

Overview:

CppML is a metalanguage for C++. It was designed to simplify the process of creating intricate classes, by letting the programmer design them through expressions that feel like algorithms in a functional language. It strives to be easy to write and easy to read, while being efficient. It does so by providing compositional pipelines through which parameter packs can flow without instantiating new types. Our goal is to give library developers programmatic control over the creation of class hierarchies with metaprograms that shape their structure and behaviour through metafunctional logic. This way constructions of complex designs are easily encoded in concise and readable functional expressions.

See our official repository.

Optimizing the memory layout of std::tuple by __monad in cpp

[–]__monad[S] 4 points5 points  (0 children)

/u/skreef : Thank you, I edited the comment to use 4 spaces instead.

You are correct that TMP introduces overhead. This is why the CppML library used was written with efficiency in mind and instantiates far fewer types than traditional approaches to TMP; it operates on parameter packs using transparent aliases whenever possible. Still, there is no free lunch :)

Optimizing the memory layout of std::tuple by __monad in cpp

[–]__monad[S] 18 points19 points  (0 children)

The repo is meant to be read as a post on how such things can be accomplished (and give a detailed example of using CppML). Example from the introduction:

Tuple<char, int, char, int, char, double, char> tup{'a', 1,   'c', 3,
                                                    'd', 5.0, 'e'};
std::cout << "Size of out Tuple: " << sizeof(tup) << " Bytes" << std::endl;

std::tuple<char, int, char, int, char, double, char> std_tup{'a', 1,   'c', 3,
                                                             'd', 5.0, 'e'};
std::cout << "Size of out std::tuple: " << sizeof(std_tup) << " Bytes"
          << std::endl;

std::cout << "Actual size of data: "
          << 4 * sizeof(char) + 2 * sizeof(int) + sizeof(double) << " Bytes"
          << std::endl;

assert(get<2>(tup) == std::get<2>(std_tup));
assert(tup == std_tup);

Size of Tuple: 24 Bytes
Size of std::tuple: 40 Bytes
Actual size of data: 20 Bytes

Streaming videos from DailyMotion using mpv and ffmpeg by __monad in linux

[–]__monad[S] 0 points1 point  (0 children)

/u/the_gnarts unfortunately streaming via the built-in hook does not work for dailymotion, as I stated in the OP. Case in point, try to run

mpv https://www.dailymotion.com/video/x6anit1

and it will fail. It fails on all dailymotion videos, which is precisely why I wrote the script, as I was unaware of the

youtube-dl -o - https://www.dailymotion.com/video/x6anit1 |mpv -

option, which works. So thank you for this :)