erreur de compilation : no matching function for call to from_chars
Bonjour.
je sèche depuis un moment sur la compilation d'un bout de code.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| #include <algorithm>
#include <cassert>
#include <fstream>
#include <charconv>
#include <iostream>
#include <string_view>
#include <iomanip>
#include <optional>
#include <system_error>
#include "Matrice.hpp"
...
void Matrice::charger(std::string const &fichier_source)
{
std::ifstream lecture (fichier_source);
std::string ligne {""};
int valeur{};
while (std::getline(lecture, ligne))
{
char sep {','};
//std::string::iterator debut {std::begin(ligne)};
//std::string::iterator fin {std::end(ligne)};
//std::string::iterator pos_sep {};
//auto debut {std::begin(ligne)};
//auto fin {std::end(ligne)};
auto debut {ligne.begin()};
auto fin {ligne.end()};
auto pos_sep {debut};
pos_sep=find_if(debut,fin,sep);
std::from_chars(debut, pos_sep-1 , m_nb_lignes);
... |
J'ai "gratté" autant que j'ai pu cppreference.com mais je n'ai pas trouvé mon erreur.
À la compilation, il bloque sur l'appel à from_chars.
Citation:
C:\Users\1.formation.fr69\Documents\codeblocks\exoZestDeSavoir\Matrice\src\Matrice.cpp|38|error: no matching function for call to
'from_chars(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >&, __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, int&)'|
j'ai ajouté toutes les bibliothèques citées dans les exemple, j'ai essayé d'ajouter 10 en dernier argument pour la base (apparemment, c'est optionnel), même résultat.
j'ai essayé plein de choses en vain...
L'un d'entre vous saurait-il m'expliquer où je commets une erreur ?
j'avis oublié. ci dessous, ma classe Matrice où sont définis m_nb_lignes et m_nb_colonnes.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #ifndef MATRICE_HPP_INCLUDED
#define MATRICE_HPP_INCLUDED
#include <vector>
class Matrice
{
public:
// constructeurs
Matrice()=default;
Matrice(int nb_lignes, int nb_colonnes);
void charger(std::string const &fichier);
void afficher ();
private:
int m_nb_lignes {1};
int m_nb_colonnes {1};
std::vector<int> m_valeurs {};
};
#endif // MATRICE_HPP_INCLUDED |