concepts/copy_constructible) < T  > ;  |  |  (since C++23)   
constexpr  explicit  single_view  (  T  && t  )  ;  |  (3)  |  (since C++20)   
template  < class  ...  Args  >  
requires [ std::  constructible_from
](http://en.cppreference.com/w/cpp/concepts/constructible_from) < T, Args...
>  
constexpr  explicit  single_view  (  [ std::  in_place_t  ](http://en.cppreference.com/w/cpp/utility/in_place) , Args  && ...  args  )  ;  |  (4)  |  (since C++20)   
|  |   
  
Constructs a ` single_view ` .

1)  Default initializes ` value_ ` , which value-initializes its contained
value.

2)  Initializes ` _value__ ` with  t  .

3)  Initializes ` _value__ ` with  std  ::  move  (  t  )  .

4)  Initializes ` _value__ ` as if by  ` _value__ ` {  [ std::  in_place
](http://en.cppreference.com/w/cpp/utility/in_place) , [ std::  forward
](http://en.cppreference.com/w/cpp/utility/forward) < Args  > (  args  )  ...
}  .

##  std::ranges::single_view::  begin

constexpr  T  *  begin  (  )  noexcept  ;  
constexpr  const  T  *  begin  (  )  const  noexcept  ;  |  |  (since C++20)   
---|---|---  
|  |   
  
Equivalent to  return  data  (  )  ;  .

##  std::ranges::single_view::  end

constexpr  T  *  end  (  )  noexcept  ;  
constexpr  const  T  *  end  (  )  const  noexcept  ;  |  |  (since C++20)   
---|---|---  
|  |   
  
Equivalent to  return  data  (  )  \+  1  ;  .

##  std::ranges::single_view::  size

static  constexpr  [ std::  size_t  ](http://en.cppreference.com/w/cpp/types/size_t) size  (  )  noexcept  ;  |  |  (since C++20)   
---|---|---  
|  |   
  
Equivalent to  return  1  ;  .

This is a static function. This makes ` single_view ` model  /*tiny-range*/
as required by [ ` split_view ` ](/w/cpp/ranges/split_view "cpp/ranges/split
view") .

##  std::ranges::single_view::  data

constexpr  T  *  data  (  )  noexcept  ;  
constexpr  const  T  *  data  (  )  const  noexcept  ;  |  |  (since C++20)   
---|---|---  
|  |   
  
Returns a pointer to the contained value of ` _value__ ` . The behavior is
undefined if ` _value__ ` does not contains a value.

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/single_view&action=edit&section=3 "Edit
section: Deduction guides") ]  Deduction guides

template  < class  T  >  
single_view  (  T  )  \-  > single_view  < T  > ;  |  |  (since C++20)   
---|---|---  
|  |   
  
###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/single_view&action=edit&section=4 "Edit
section: Notes") ]  Notes

For a  ` single_view ` , the inherited ` empty ` member function always
returns  false  , and the inherited  operator  bool  conversion function
always returns  true  .

###  [ [ edit
](/mwiki/index.php?title=cpp/ranges/single_view&action=edit&section=5 "Edit
section: Example") ]  Example

Run this code

    
    
    #include <iomanip>
    #include <iostream>
    #include <ranges>
    #include <string>
    #include <tuple>
     
    int main()
    {
        constexpr std::ranges::single_view sv1{3.1415}; // uses (const T&) constructor
        static_assert(sv1);
        static_assert(not sv1.empty());
     
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "1) *sv1.data(): " << *sv1.data() << '\n'
                  << "2) *sv1.begin(): " << *sv1.begin() << '\n'
                  << "3)  sv1.size(): " << sv1.size() << '\n'
                  << "4)  distance: " << [std::distance](http://en.cppreference.com/w/cpp/iterator/distance)(sv1.begin(), sv1.end()) << '\n';
     
        [std::string](http://en.cppreference.com/w/cpp/string/basic_string) str{"C++20"};
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "5)  str = " << [std::quoted](http://en.cppreference.com/w/cpp/io/manip/quoted)(str) << '\n';
        std::ranges::single_view sv2{std::move(str)}; // uses (T&&) constructor
        [std::cout](http://en.cppreference.com/w/cpp/io/cout) << "6) *sv2.data(): " << [std::quoted](http://en.cppreference.com/w/cpp/io/manip/quoted)(*sv2.data()) << '\n'
                  << "7)  str = " <<