Skip to content

Help wanted: error C2338: static_assert failed: 'Cannot format an argument. To make type T formattable, provide a formatter<T> specialization.  #4093

Description

          > Most likely it is your bug, you are trying to format something that is not formattable. In any case, maintainers can't help without a repro.

I encounter this issue again, and this is my code

std::string debug_int_surf_surf(surf_surf_int* items, std::string name, const double kCurveParamStep) {
    std::string info;
    int id = 0;
    if(!items) {
        return name + ":no intersection\n";
    }
    while(items) {
        switch(items->int_type) {
            case surf_int_type::int_normal:  // 	Normal (usual) intersection.
                info += std::format("{} {} is a normal intersection\n", name, id);
                break;
            case surf_int_type::int_tangent:  // 	Tangent or coincident intersection, with normals in the same direction.
                info += std::format("{} {} is a tangent intersection\n", name, id);
                break;
            case surf_int_type::int_antitangent:  // Tangent or coincident intersection, with normals in opposite direction.
                info += std::format("{} {} is a antitangent intersection\n", name, id);
                break;
        }
        curve* curve = items->cur;
        if(!curve) {
            SPAposition p = items->end_term->term_pos;
            info += std::format("({} {}) point: ({},{},{})\n\tisolate point\n",  //
                                name,
                                id,                  //
                                p.x(), p.y(), p.z()  //
            );
            items = items->next;
            ++id;
            continue;
        }
        SPAinterval range = curve->param_range();
        double t;
        for(t = range.start_pt(); t <= range.end_pt(); t += kCurveParamStep) {
            SPAposition p;
            curve->eval(t, p);
            info += std::format(                              //
              "({} {}) point:({:.10f}, {:.10f}, {:.10f})\n",  //
              name, id, p.x(), p.y(), p.z());
        }
        t = range.end_pt();
        SPAposition p;
        curve->eval(t, p);
        info += std::format(                              //
          "({} {}) point:({:.10f}, {:.10f}, {:.10f})\n",  //
          name, id, p.x(), p.y(), p.z()                   //
        );

        if(name == "ACIS") {
            pcurve* p_curve = items->pcur2;
            if(p_curve) {
                SPAinterval param_range = p_curve->param_range();
                for(double t = param_range.start_pt(); t <= param_range.end_pt(); t += kCurveParamStep) {
                    SPApar_pos p = p_curve->eval_position(t);
                    info += std::format(            //
                      "(ACIS {}) param:({},{})\n",  //
                      id, p.u, p.v);
                }
            }
        }

        ++id;
        items = items->next;
    }
    return info;
}

This code is correct in VS 2019

Originally posted by boshuo chen (@chenboshuo) in #3860 (comment)

#3860 can't reopen

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis issue is incorrect or by design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions