<commit_before>/*==========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkScalar.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) National Library of Medicine
  All rights reserved.

  See COPYRIGHT.txt for copyright details.
  
  ==========================================================================*/
#ifndef __itkScalar_h
#define __itkScalar_h

#include "itkMacro.h"

namespace itk
{

/** \class Scalar
 * \brief A templated class holding a single scalar value and responding to
 *        the GetScalar() method.
 * 
 * Scalar is a templated class that holds a single scalar value.
 * Scalar can be used as the data type held at each pixel in an Image
 * or at each vertex (or cell) of an Mesh. The template parameter can be
 * any data type that behaves like a primitive (or atomic) data type (int,
 * short, float, complex).  itk filters that rely on scalar data assume the
 * data type held at each pixel or each vertex responds to
 * GetScalar()/SetScalar() methods. If not, a compile time error will occur.
 *
 * For efficiency sake, Scalar does not define a default constructor, a
 * copy constructor, or many operators. We rely on the compiler to provide
 * efficient methods.
 *
 * If you wish more complex pixel types, you can use Vector, which
 * represents an array values of the same data type. There is also an
 * ScalarVector, which supports (for a given pixel) a single scalar value
 * plus an array of vector values. (The scalar and vectors can be of
 * different data type.)
 * 
 * \sa Image
 * \sa Mesh
 * \sa Vector
 * \sa ScalarVector 
 */

template<class T>
class Scalar {
public:
  /**
   * Standard "Self" typedef.
   */
  typedef Scalar Self;
  
  /**
   * ValueType can be used to declare a variable that is the same type
   * as the data held in an Scalar.
   */
  typedef T ValueType;

  /**
   * ScalarValueType can be used to declare a variable that is the same type
   * as the data held in an Scalar.
   */
  typedef T ScalarValueType;

  /**
   * Get the dimension (size) of this scalar. The method is necessary
   * to satisfy the pixel manipulation API.
   */
  static unsigned int GetPixelDimension() 
    { return 1; }  

  /**
   * Set the scalar value.
   * \sa GetScalar()
   */
  void SetScalar(const T &val) { m_Scalar = val; }

  /**
   * Get the scalar value.
   * \sa SetScalar()
   */
  T& GetScalar()
  { return m_Scalar; }
  
  /**
   * Get the scalar value.
   * \sa SetScalar()
   */
  const T& GetScalar() const
  { return m_Scalar; }
  
  /**
   * Operator to get (cast) the scalar value. This version can be used as
   * an lvalue. Note that by returning a reference to T, the compiler now
   * has a way to implicitly create operator==, operator>, operator+,
   * operator+=, etc.
   */
  operator T& ()
  { return m_Scalar; };

  /**
   * Operator to get the scalar value as an rvalue.
   * This cannot be "operator const T& () const" because that would
   * ambiguate "operator T& ()" when either is allowed.
   */
  operator T () const
  { return m_Scalar; };
  
  /**
   * Operator to set the scalar value.
   */
  Self& operator= (const T &val) { m_Scalar = val; return *this;}
  
  
private:
  T m_Scalar;
};

  
/**
 * An output stream operator to write out the scalar through the real
 * scalar's output stream operator.  This prevents implicit conversion
 * ambiguities.
 */
template <typename T>
ostream& operator << (ostream& os, const Scalar<T>& s)
{
  os << s.GetScalar();
}

} // end namespace itk
  
#endif <commit_msg>ERR: Added std:: before ostream to properly qualify namespace.<commit_after>/*==========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkScalar.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) National Library of Medicine
  All rights reserved.

  See COPYRIGHT.txt for copyright details.
  
  ==========================================================================*/
#ifndef __itkScalar_h
#define __itkScalar_h

#include "itkMacro.h"

namespace itk
{

/** \class Scalar
 * \brief A templated class holding a single scalar value and responding to
 *        the GetScalar() method.
 * 
 * Scalar is a templated class that holds a single scalar value.
 * Scalar can be used as the data type held at each pixel in an Image
 * or at each vertex (or cell) of an Mesh. The template parameter can be
 * any data type that behaves like a primitive (or atomic) data type (int,
 * short, float, complex).  itk filters that rely on scalar data assume the
 * data type held at each pixel or each vertex responds to
 * GetScalar()/SetScalar() methods. If not, a compile time error will occur.
 *
 * For efficiency sake, Scalar does not define a default constructor, a
 * copy constructor, or many operators. We rely on the compiler to provide
 * efficient methods.
 *
 * If you wish more complex pixel types, you can use Vector, which
 * represents an array values of the same data type. There is also an
 * ScalarVector, which supports (for a given pixel) a single scalar value
 * plus an array of vector values. (The scalar and vectors can be of
 * different data type.)
 * 
 * \sa Image
 * \sa Mesh
 * \sa Vector
 * \sa ScalarVector 
 */

template<class T>
class Scalar {
public:
  /**
   * Standard "Self" typedef.
   */
  typedef Scalar Self;
  
  /**
   * ValueType can be used to declare a variable that is the same type
   * as the data held in an Scalar.
   */
  typedef T ValueType;

  /**
   * ScalarValueType can be used to declare a variable that is the same type
   * as the data held in an Scalar.
   */
  typedef T ScalarValueType;

  /**
   * Get the dimension (size) of this scalar. The method is necessary
   * to satisfy the pixel manipulation API.
   */
  static unsigned int GetPixelDimension() 
    { return 1; }  

  /**
   * Set the scalar value.
   * \sa GetScalar()
   */
  void SetScalar(const T &val) { m_Scalar = val; }

  /**
   * Get the scalar value.
   * \sa SetScalar()
   */
  T& GetScalar()
  { return m_Scalar; }
  
  /**
   * Get the scalar value.
   * \sa SetScalar()
   */
  const T& GetScalar() const
  { return m_Scalar; }
  
  /**
   * Operator to get (cast) the scalar value. This version can be used as
   * an lvalue. Note that by returning a reference to T, the compiler now
   * has a way to implicitly create operator==, operator>, operator+,
   * operator+=, etc.
   */
  operator T& ()
  { return m_Scalar; };

  /**
   * Operator to get the scalar value as an rvalue.
   * This cannot be "operator const T& () const" because that would
   * ambiguate "operator T& ()" when either is allowed.
   */
  operator T () const
  { return m_Scalar; };
  
  /**
   * Operator to set the scalar value.
   */
  Self& operator= (const T &val) { m_Scalar = val; return *this;}
  
  
private:
  T m_Scalar;
};

  
/**
 * An output stream operator to write out the scalar through the real
 * scalar's output stream operator.  This prevents implicit conversion
 * ambiguities.
 */
template <typename T>
std::ostream& operator << (std::ostream& os, const Scalar<T>& s)
{
  os << s.GetScalar();
}

} // end namespace itk
  
#endif 
{'fraction_non_alphanumeric': 0.12967786154900618, 'fraction_numerical': 0.00027416038382453733, 'mean_word_length': 3.0087912087912088, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2189975', 'n_tokens_mistral': 2136, 'n_tokens_neox': 2070, 'n_words': 940}